save basket /Get current basket



//Get current basket
           var basket = ShopApi.Basket.GetCurrentBasket(falseas Basket;
 
           //Update basket with PaymentMethodExtraOptions
           basket.PaymentMethodExtraOptions = model.PaymentMethodExtraOptions;
           CommerceFramework.Baskets.SaveBasket(basket);













Remove item value by llinq


REmove item value by llinq

//Remove WarehouseId on main Basket to get all warehouese details on calculate basket. 
            mainbasket.Select(c => { ((BasketLine)c).RequestWarehouseId = nullreturn c; }).ToList();

new link button with url / url.Action

Kings Project
add button to the view

@Sana.LinkButton(textKey: "PayNextOrder",
                url: ((ExtendedUrlsBuilder)Url.Sana).ShowPayNextOrder(Url.GetReturnUrl()),
                cssClass: "btn btn-medium", altTextKey: "PayNextOrder", defaultText: "Pay Next Order")


update url redirection on control
public class ExtendedCheckoutController : CheckoutController
   {
       protected override void RegisterSystemRoutes(Commerce.Web.Routing.SanaRouteCollection routes)
       {
           routes.MapSystemPageRoute(Name, "PaymentMethodsAndShippingAddress""PaymentMethodsAndShippingAddress""checkout/paymentandshipping");
           routes.MapSystemPageRoute(Name, "ShowPayNextOrder""ShowPayNextOrder""checkout/showpaynextorder");
 
           base.RegisterSystemRoutes(routes);
       }
   }


update urlbuilder

public class ExtendedUrlsBuilder : UrlsBuilder
    {
        public ExtendedUrlsBuilder(RouteCollection routes) : base(routes)
        {
        }
 
        /// <summary>
        /// Gets the rentals URL.
        /// </summary>
        /// <param name="returnUrl">The return URL.</param>
        /// <returns></returns>
        public virtual string ShowPayNextOrder(string returnUrl = null)
        {
            return GetUrlForRoute("ShowPayNextOrder"new { returnUrl });
        }
    }








 another way :- 
<a href="@Url.Action("DeleteOrderAndBackToBasket","checkout",new { Model.OrderId })" class="no-icon btn-back font-btn">@Sana.SimpleText("CreditCardManagement_Back_Basket""CreditCardManagement_Back_Basket")</a>


// Ticket 102771: [PRL Glass] 3.3. Download Customer Statement report from My Account
            // Add Button with and set target = "_blank" to open in new window.
 @Sana.LinkButton(textKeyreportName.ToString(),
 url: Url.Action("CustomerStatmentReport""ErpFileDownload"new { customerId = customerId.ToString() }),
 cssClass"btn btn-report"defaultTextreportName.ToString(), htmlAttributesnew { rel = "nofollow", target = "_blank" })













NHibernate Return collection and single object

return collection

public class ExtendedShopAccountProvider : ShopAccountProvider
   {
       //3.4. LOGIN WITH ERP NUMBER
       /// <summary>
       /// This method will get Shop Accounts by Account Id.
       /// </summary>
       /// <param name="accountId"></param>
       /// <returns></returns>  
       public virtual IShopAccountCollection GetShopAccountsByAccountId(string accountId)
       {
           Guard.ThrowIfEmptyString(accountId, "accountId""AccountId cannot be empty.");
 
           var result = WrapDataAccessException(() =>
           {
               using (var sm = CreateSessionManager(true))
               {
                   var criteria = sm.Session.CreateCriteria(GetRegisteredType<IShopAccount>());
                   criteria.Add(Expression.Eq("ReferenceId", accountId));
                   criteria.Add(Expression.Eq("Activated"true));
                   criteria.Add(Expression.Eq("ShopAccountType"ShopAccountType.Customer));
                   criteria.Add(Expression.Eq("WebsiteId", Context.WebsiteId));
 
                   var countCriteria = CriteriaTransformer.TransformToRowCount(criteria);
                   int totalCount = countCriteria.UniqueResult<int>();
 
                   var results = criteria.List<IShopAccount>();
                   var collection = ObjectFactory.Create<IShopAccountCollection>();
                   collection.Initialize(results, totalCount);
                   return collection;
               }
           }, "Cannot get the list of shop accounts.");                         
           return result;
 
       }

single

public virtual IShopAccount GetShopAccountByEmail(string email)
        {
            Guard.ThrowIfEmptyString(email, "email""Email cannot be empty.");

            return WrapDataAccessException(() =>
            {
                using (var sm = CreateSessionManager(true))
                {
                    var criteria = sm.Session.CreateCriteria(GetRegisteredType<IShopAccount>());
                    criteria.Add(Expression.Eq("Email", email));
                    criteria.Add(Expression.Eq("WebsiteId", Context.WebsiteId));
                    return criteria.UniqueResult<IShopAccount>();
                }
            }, "Cannot get shop account by email: Email = {0}, WebsiteId = {1}.",
            email, Context.WebsiteId);
        }




Pass String List and get List Object 

public virtual IList<IProductEnrichment> GetProductEnrichments(IList<string> productIds)
        {
            if (productIds.Count == 0)
                return new List<IProductEnrichment>();

            return WrapDataAccessException(() =>
            {
                using (var sm = CreateSessionManager(true))
                {
                    var criteria = sm.Session.CreateCriteria(GetRegisteredType<IProductEnrichment>())
                        .Add(Restrictions.Eq("WebsiteId", Context.WebsiteId));

                    var collection = GetListByPortions(criteria, "ProductId", productIds);
                    return collection.Cast<IProductEnrichment>().ToList();
                }
            }, "Cannot get products enrichments for products with IDs = {0} and website = {1}.", productIds.JoinWith(", "), Context.WebsiteId);
        }


Get List
/// Ticket 88704: [Kavo] 3.9. PDP – RELATED ITEMS
        /// <summary>
        /// Get related product sets
        /// </summary>
        /// <returns>List of related product items</returns>
        public IList<IRelatedProductSet> GetRelatedProductSets()
        {
            return WrapDataAccessException(() =>
            {
                using (var sm = CreateSessionManager(true))
                {
                    var criteria = sm.Session.CreateCriteria(GetRegisteredType<IRelatedProductSet>());
                    criteria.Add(Expression.Eq("WebsiteId", Context.WebsiteId));
                    return criteria.List<IRelatedProductSet>();
                }
            }, "Cannot get related product sets: WebsiteId = {0}.", Context.WebsiteId);
        }

Update/Save object
/// Ticket 88704: [Kavo] 3.9. PDP – RELATED ITEMS
        /// <summary>
        /// Save/Update related product set
        /// </summary>
        /// <param name="relatedProductSet">related product set object</param>
        public void UpdateRelatedProductSet(IRelatedProductSet relatedProductSet)
        {
            WrapDataAccessException(() =>
            {
                using (var sm = CreateSessionManager(false))
                {
                    sm.Session.Merge(relatedProductSet);
                    sm.Commit();
                }
            }, "Cannot update related product sets: Id = {0}, CategoryId = {1}, WebsiteId = {2}.",
           relatedProductSet.Id, relatedProductSet.CategoryId, relatedProductSet.WebsiteId);
        }


Filter by table element.

/// Ticket 88704: [Kavo] 3.9. PDP – RELATED ITEMS
        /// <summary>
        /// Get related product set
        /// </summary>
        /// <param name="categoryId">category id</param>
        /// <returns>related product set</returns>
        public IRelatedProductSet GetRelatedProductSetByCategoryId(string categoryId)
        {
            return WrapDataAccessException(() =>
            {
                using (var sm = CreateSessionManager(true))
                {
                    var criteria = sm.Session.CreateCriteria(GetRegisteredType<IRelatedProductSet>());
                    criteria.Add(Expression.Eq("WebsiteId", Context.WebsiteId));                   
                    criteria.Add(Expression.Eq("CategoryId", categoryId));                   
 
                    return criteria.UniqueResult<IRelatedProductSet>();
                }
            }, "Cannot get related products set: CategoryId = {0}, WebsiteId = {1}.", categoryId, Context.WebsiteId);
        }

IN operator 
/// Ticket 88704: [Kavo] 3.9. PDP – RELATED ITEMS
/// <summary>
/// Get related product items by category ids.
/// </summary>
 /// <param name="categoryId">category id</param>
 /// <returns>related product item</returns>
 public IList<IRelatedProductSet> GetRelatedProductSetsByCategoryIds(List<string> categoryIds)
  {
      if (categoryIds.Count == 0)
          return new List<IRelatedProductSet>();

         return WrapDataAccessException(() =>
         {
             using (var sm = CreateSessionManager(true))
             {
                    var criteria = sm.Session.CreateCriteria(GetRegisteredType<IRelatedProductSet>())
                       .Add(Restrictions.Eq("WebsiteId", Context.WebsiteId))
                       .Add(Expression.In("CategoryId", categoryIds));   <----------                  
                    return criteria.List<IRelatedProductSet>();                     

             }
         }, "Cannot get related products set for products with Ids = {0} and website = {1}.", categoryIds.JoinWith(", "), Context.WebsiteId);
                       
 }