Refresh Page controller and java script

 refresh by : controler > 

return Redirect(Request.UrlReferrer.ToString());


public virtual ActionResult Remove(string productId, string variationId, string prepackId, string unitOfMeasureId, string salesAgreementLineNo)
        {
            var lines = ShopApi.Basket.ExtractLines(productId, variationId, prepackId, unitOfMeasureId, salesAgreementLineNo);
            if (lines.Any())
            {
                var result = CreateTrackingModelForModifiedBasketLines(lines);
                //return Json(result);
                return Redirect(Request.UrlReferrer.ToString());
            }
            return Json(false); 
        }


by java script

location.reload();
function sendPromoCode() {
                var newOrderTemplateName = $("#txtPromotionCode").val();
 
                alert(newOrderTemplateName);
 
                $.ajax({
                    url: Sana.Urls.Home() + 'basket/showpaynextorder',
                    method: "POST",
                    data: { code: newOrderTemplateName }
                    ,
                    error: function () {
                        alert("Ajax call failed");
                    }
                }).done(function (data) {
 
                    alert("ok");
                    location.reload();                  

                })
            }



How to Stop task Service if can not stop by right click and stop

 Hot to Stop Service if can not stop by right click and stop



how to decrypt Task service Sana.Commerce.TaskService.exe

go to this link download 'decrypt-web-config.ps1' and follow as it.

https://sanacommerce.visualstudio.com/Sana%20Projects/_wiki/wikis/Sana-Projects.wiki/895/PS-script-to-decrypt-the-web.config-content

change only connection string
C:\windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis -pdf "connectionStrings"  "D:\MyFolderforEncrypt"

if files not decrypt then the problem may be with the service 



---------------------------------------------------------------------------------------------------------

1. when tries to stop service it gives the following error. 




2. Task service will not be stopped if application bin folder dll and Task service dll are not matched, 
then we unable to stop the Task service. 

force a service to stop service https://support.threattracksecurity.com/support/solutions/articles/1000070698-how-to-manually-force-a-service-to-stop-if-not-responding



run > sc queryex "SC CoulisseLiveNew"

get the PID  1912

again run with PID : taskkill /pid 1912 /f

Then go to servises and refresh and check servise has stoped. 


 







Add Validation to a Model State and Show Error in field (server side validation)



on This Example Add Validation to OrderOverviewModel > AdditionalInfo.DeliveryDate

OrderOverviewModel > AdditionalInfo.DeliveryDate


        private void ValidateRequestedDeliveryDate(OrderOverviewModel model)
         {            
            var basket = ShopApi.Basket.GetCurrentBasket(false) as Basket;
            var deliveryDate = (Date)model.AdditionalInfo.DeliveryDate;
 
            var deliveryDateModel = ((ExtendedOrderManager)CommerceFrameworkBase.Orders).SetDeliveryDateModel(basket.DeliveryCalendarDates);                       
            var requestedDateContainOnDissableDatesList = deliveryDateModel.Holidays.Contains(deliveryDate);
 
            // Validate user Enterd Delivery not in Disable dates 
            if (requestedDateContainOnDissableDatesList)
            {
                ((ExtendedAdditionalInfoModel)model.AdditionalInfo).DisableDays = deliveryDateModel.HolidaysStringList;
                ((ExtendedAdditionalInfoModel)model.AdditionalInfo).DeliveryLookupPeriod = deliveryDateModel.DeliveryLookupPeriod;
 
                // Set requested date as NextPossibleDeliveryDate. when validation occured.
                ((ExtendedAdditionalInfoModel)model.AdditionalInfo).NextPossibleDeliveryDate = deliveryDate.ToShortDateString();
 
                // Set Cut off time validatation to Model State.
                var validationCutOff = CommerceFrameworkBase.SanaTexts.GetSanaText("Validation_CutOff", "Requested delivery date is invalid or the cut off time has been missed.");
                ModelState.AddModelError("AdditionalInfo.DeliveryDate", validationCutOff);
            } 

        } 

public override ActionResult OrderOverview(OrderOverviewModel model)
        {
            var incompleteStepUrl = GetFirstIncompleteStepUrl(OrderOverviewCheckoutStep.StepId);
            if (!incompleteStepUrl.IsEmptyString())
                return Redirect(incompleteStepUrl);
 
            // Ticket 79457: [Wave 2] 3.5. CUT-OFF TIME FOR DELIVERY
            ValidateRequestedDeliveryDate(model);
 
            if (!ModelState.IsValid)
            {
                var info = InitializeStep(OrderOverviewCheckoutStep.StepId);
                model.InitializeGeneral(Shop, info.Value);
                model.PageSettings = GetSystemPageSettings(SystemPagesConstants.CheckoutPages);
                return View(model);
            }
            ModifyBasket(model.ApplyChanges);
            return GoToNextCheckoutStep(OrderOverviewCheckoutStep.StepId);
        }




How to update Theam

ExtendedThemeModel : ThemeModel


[Display(Name = "Theme_Status_discontinued", GroupName = "Theme_Status", Order = 100)]
public virtual string Status_Failed_BackgroundColor { getset; }




update Admin.resx with names

3. add Theme.css or relevent css and add css to code.

.checkout-page-cnt #representChildAddressPage .representChild-btn {
    background-color[Checkout_PlaceOrderForSubsidiary_BackgroundColor|#f78400];
    /*border-color: [Checkout_PlaceOrderForSubsidiary_BackgroundColor|#000];*/
}



how to get product url

var options = ObjectFactory.Create<IProductLoadOptions>();
                           var newProduct = CommerceFrameworkBase.Products.GetProduct(productReplacedWith, options);
                           var productUrl = newProduct != null ? Url.Sana.Product(newProduct) : null;






dff

Basket related changes.

 Ticket 69559: 3.3. DISPLAY STOCK FOR EACH ITEM IN BASKET https://sanacommerce.visualstudio.com/Sana%20Projects/_workitems/edit/69559/




1.BasketInfoCellContext


public class BasketInfoCellContext
    {
        public ISalesLine Line { getset; }
        public string ProductUrl { getset; }
        public string ProductTitle { getset; }
        public string ProductId { getset; }
        //[69559]3.3. DISPLAY STOCK FOR EACH ITEM IN BASKET
        public StockModel StockModel { get; set; }
        public bool ReadOnly { getset; }
        public IList<ISalesLine> ExtendedLines { getset; }
        public bool SingleLineMode { getset; }
        public bool HasComponentTitle { getset; }
        public int LineIndex { getset; }
        public string ConfiguredProductDescription { getset; }
    }

2.BasketExtensions.cs

Add new infoCell  method

public static IHtmlString InfoCell(this HtmlHelper htmlHelper, ISalesLine line, string productUrl,
            string productTitle, string productId, bool readOnly, IList<ISalesLine> extendedLines = null,
            bool singleLineMode = truebool hasComponentTitle = falseint lineIndex = 0,
            string configuredProductDescription = nullStockModel stockModel = null)
        {
            var context = new BasketInfoCellContext
            {
                Line = line,
                ProductUrl = productUrl,
                ProductTitle = productTitle,
                ProductId = productId,
                ReadOnly = readOnly,
                ExtendedLines = extendedLines,
                SingleLineMode = singleLineMode,
                HasComponentTitle = hasComponentTitle,
                LineIndex = lineIndex,
                ConfiguredProductDescription = configuredProductDescription,
                //[69559]3.3. DISPLAY STOCK FOR EACH ITEM IN BASKET
                StockModel =stockModel
            };
            return CompiledHelpers.Themed(BasketHelpers.InfoCell, context);
        }


3._BasketLinesB2B.cshtml

@helper SimpleProductLine(SimpleProductLine productLine)
{
var line = productLine.SalesLine;
//[69559]3.3. DISPLAY STOCK FOR EACH ITEM IN BASKET
int productQuantity = (int)CommerceFrameworkBase.Stock.GetStockInfo(@line.ProductId, new StockInfoLoadOptions()).FirstOrDefault().Inventory;
var product = CommerceFrameworkBase.Products.GetProduct(line.ProductId, new ProductLoadOptions());
var stockRange = CommerceFrameworkBase.Stock.GetStockRangeFor(product);
var stockModel = new StockModel();
stockModel.StockRange = stockRange;
stockModel.Inventory = productQuantity;
var productUrl = productLine.Product != null && productLine.Product.Visible ? Url.Sana.Product(productLine.Product) : null;
var index = Next();
    <tr class="upper-row row-simple-product" data-productid="@line.ProductId" data-unitofmeasureid="@line.UnitOfMeasureId"
        data-salesagreementlineno="@line.SalesAgreementLineNo"
        data-tracking-data="@productLine.ProductTrackingDataModel.ToJson(encode: true)">
        <td class="col-first">
            @if (Model.ShowImages)
            {
                @Html.ImageCell(productLine.DisplayImage, productUrl, line.ProductTitle)
            }
        </td>
        <td class="col-info clearfix">
            @Html.InfoCell(line,
                            productUrl,
                            line.ProductTitle,
                            line.ProductId,
                            line.IsNonEditableItem,
                            productLine.ExtendedTexts,
                            lineIndex: index,
                            configuredProductDescription: productLine.ConfiguredProductDescription,
                            stockModel:stockModel                            
                            )
        </td>
        <td class="col-price">


BasketHelpers.cshtml


Add stock lable to quick order.

Ravensburg  Ticket 113689: [Ravensburger - Phase 2] 3.1. Display stock availability in the shopping cart. 
 

go to :https://www.blogger.com/blog/post/edit/7752405819139694131/7793167428942590653
search :Quick order / knowkout add variable to quick order