Beispiel #1
0
        public async Task <object> UpdateProductBrandToZero(string userId)
        {
            var pUserId = Guid.Parse(userId);

            try
            {
                var deleteProdBrand = await HanomaContext.ProductBrand.FirstOrDefaultAsync(p => p.CreateBy == pUserId);

                if (deleteProdBrand != null)
                {
                    HanomaContext.ProductBrand.RemoveRange(deleteProdBrand);
                    HanomaContext.SaveChanges();
                }
                var updateAspNetUserProfiles = await HanomaContext.AspNetUserProfiles.FirstOrDefaultAsync(p => p.UserId == userId);

                if (updateAspNetUserProfiles != null)
                {
                    updateAspNetUserProfiles.ProductBrand_ID = 0;
                    HanomaContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(new object());
        }
Beispiel #2
0
        public async Task <List <DashBoashProductBrand_Result> > GetDashBoard(string UserId)
        {
            var userProfile = HanomaContext.AspNetUserProfiles.FirstOrDefault(p => p.UserId == UserId);

            if (userProfile != null && userProfile.ProductBrand_ID > 0)
            {
                try
                {
                    //init param
                    var Tag            = new SqlParameter("@pTag", (object)DBNull.Value);
                    var ProductBrandID = new SqlParameter("@pProductBrandID", userProfile.ProductBrand_ID);

                    var result = await HanomaContext.Set <DashBoashProductBrand_Result>()
                                 .FromSqlRaw($"EXECUTE dbo.DashBoashProductBrand "
                                             + $"@pTag = @pTag, "
                                             + $"@pProductBrandID = @pProductBrandID ", Tag, ProductBrandID)
                                 .AsNoTracking()
                                 .ToListAsync();

                    return(result);
                }
                catch (Exception ex)
                {
                }
            }
            return(new List <DashBoashProductBrand_Result>());
        }
Beispiel #3
0
        public int UpdateImgProductBrand(ProductBrand model, ImageUploadDTO imgLogo, ImageUploadDTO imgBanner, int ProductBrandId, string UserId)
        {
            var pUserId = Guid.Parse(UserId);

            if (model != null)
            {
                var prodBrandSave = HanomaContext.ProductBrand.Find(ProductBrandId);
                if (prodBrandSave != null)
                {
                    try
                    {
                        if (imgLogo.Base64 != null)
                        {
                            prodBrandSave.Logo = String.Format("{0}-mobile-logo.{1}", ProductBrandId, imgLogo.ExtensionType.Replace("image/", ""));
                        }

                        if (imgBanner.Base64 != null)
                        {
                            prodBrandSave.Banner = String.Format("{0}-mobile-banner.{1}", ProductBrandId, imgBanner.ExtensionType.Replace("image/", ""));
                        }

                        HanomaContext.SaveChanges();
                        return(model.ProductBrand_ID);
                    }
                    catch (Exception ex)
                    {
                        return(0);
                    }
                }
            }
            return(ProductBrandId);
        }
Beispiel #4
0
        public async Task <Tuple <int, IEnumerable <ProductBrand_Search_Result> > > GetListBrandPagging(int page, int pageSize, int?LocationId, int active, int?productCategoryId, string keyword)
        {
            var Keyword            = new SqlParameter("@Keyword", String.IsNullOrEmpty(keyword) ? (object)DBNull.Value : keyword);
            var Active             = new SqlParameter("@Active", active);
            var PageSize           = new SqlParameter("@PageSize", pageSize);
            var CurrentPage        = new SqlParameter("@CurrentPage", page);
            var ProductCategory_ID = new SqlParameter("@ProductCategory_ID", productCategoryId ?? (object)DBNull.Value);
            var Location_Id        = new SqlParameter("@Location_ID", LocationId ?? (object)DBNull.Value);
            var ItemCount          = new SqlParameter("@ItemCount", "")
            {
                Direction = System.Data.ParameterDirection.Output,
                DbType    = System.Data.DbType.Int32
            };

            var output = await HanomaContext.Set <ProductBrand_Search_Result>()
                         .FromSqlRaw($"EXECUTE dbo.ProductBrand_Search " +
                                     $"@Keyword = @Keyword, " +
                                     $"@Active = @Active, @PageSize = @PageSize,@Location_ID = @Location_ID, @ProductCategory_ID = @ProductCategory_ID, @CurrentPage = @CurrentPage, @ItemCount =  @ItemCount OUTPUT", Keyword, Active, PageSize, Location_Id, ProductCategory_ID, CurrentPage, ItemCount)
                         .AsNoTracking()
                         .ToListAsync();

            var ItemCountRes = Convert.ToInt32(ItemCount.Value);

            return(new Tuple <int, IEnumerable <ProductBrand_Search_Result> >(ItemCountRes, output));
        }
        public async Task <IEnumerable <GetMenuProdCateByUser_Result> > GetMenuProdCateByUser(string UserId, int?productTypeId, int?statusTypeId, int parentId = 656)
        {
            var pUserId        = new SqlParameter("@UserId", UserId ?? (object)DBNull.Value);
            var pParenId       = new SqlParameter("@ParenId", parentId);
            var pProductTypeId = new SqlParameter("@ProductTypeId", productTypeId ?? (object)DBNull.Value);
            var pStatusTypeId  = new SqlParameter("@StatusTypeId", statusTypeId ?? (object)DBNull.Value);

            try
            {
                var output = await HanomaContext.Set <GetMenuProdCateByUser_Result>()
                             .FromSqlRaw($"EXECUTE GetMenuProdCateByUser @UserId = @UserId, "
                                         + $"@ParenId = @ParenId, "
                                         + $"@ProductTypeId = @ProductTypeId, "
                                         + $"@StatusTypeId = @StatusTypeId ",
                                         pUserId, pParenId, pProductTypeId, pStatusTypeId)
                             .AsNoTracking()
                             .ToListAsync();

                return(output);
            }
            catch (Exception ex)
            {
                return(new List <GetMenuProdCateByUser_Result>());
            }
        }
Beispiel #6
0
        public async Task <IEnumerable <ProductBrand_Search_Brand_V2_Result> > GetListProductBrand(ProductBrandFilter filter)
        {
            var Keyword             = new SqlParameter("@Keyword", filter.Keyword);
            var StatusType_ID       = new SqlParameter("@StatusType_ID", filter.StatusTypeId);
            var PageSize            = new SqlParameter("@PageSize", filter.PageSize);
            var CurrentPage         = new SqlParameter("@CurrentPage", filter.Page);
            var ProductType_ID      = new SqlParameter("@ProductType_ID", filter.ProductTypeID);
            var ProductCategory_ID  = new SqlParameter("@ProductCategory_ID", filter.ProductCategoryID);
            var AccesoryCategory_ID = new SqlParameter("@AccesoryCategory_ID", filter.AccesoryCategoryID);
            var Location_ID         = new SqlParameter("@Location_ID", filter.LocationID);

            var result = await HanomaContext.Set <ProductBrand_Search_Brand_V2_Result>()
                         .FromSqlRaw($"EXECUTE dbo.ProductBrand_Search_Brand_V2 "
                                     + $"@Keyword = @Keyword, "
                                     + $"@ProductType_ID = @ProductType_ID, "
                                     + $"@ProductCategory_ID = @ProductCategory_ID, "
                                     + $"@AccesoryCategory_ID = @AccesoryCategory_ID, "
                                     + $"@Location_ID = @Location_ID, "
                                     + $"@StatusType_ID = @StatusType_ID, "
                                     + $"@PageSize = @PageSize, "
                                     + $"@CurrentPage = @CurrentPage ",
                                     Keyword, ProductType_ID, ProductCategory_ID, AccesoryCategory_ID, Location_ID, StatusType_ID,
                                     PageSize, CurrentPage
                                     )
                         .AsNoTracking()
                         .ToListAsync();

            return(result);
        }
        public async Task <CountHistoryShopingCart_Result> GetCountHistoryShopingCart(CountHistoryShoppingCart model)
        {
            var pUserId          = new SqlParameter("@UserId", model.UserId ?? (object)DBNull.Value);
            var pProductBrandId  = new SqlParameter("@ProductBrandId", model.ProductBrandId ?? (object)DBNull.Value);
            var pFromDate        = new SqlParameter("@FromDate", model.FromDate ?? (object)DBNull.Value);
            var pToDate          = new SqlParameter("@ToDate", model.ToDate ?? (object)DBNull.Value);
            var pShopingCartCode = new SqlParameter("@ShopingCartCode", model.ShopingCartCode ?? (object)DBNull.Value);

            try
            {
                var output = await HanomaContext.Set <CountHistoryShopingCart_Result>()
                             .FromSqlRaw($"EXECUTE dbo.CountHistoryShopingCart " +
                                         $"@UserId = @UserId, " +
                                         $"@ProductBrandId = @ProductBrandId, " +
                                         $"@ShopingCartCode = @ShopingCartCode, " +
                                         $"@FromDate = @FromDate, " +
                                         $"@ToDate = @ToDate ",
                                         pUserId, pProductBrandId, pShopingCartCode, pFromDate, pToDate
                                         )
                             .AsNoTracking()
                             .ToListAsync();

                return(output.FirstOrDefault());
            }
            catch (Exception ex)
            {
            }

            return(new CountHistoryShopingCart_Result());
        }
Beispiel #8
0
        public async Task <List <GetDashBoard_Result> > GetDashBoardPharse2(string UserId, int?CustomerFilter, int?PostFilter, int?OrderFilter, int?FinanceFilter)
        {
            var userProfile = HanomaContext.AspNetUserProfiles.FirstOrDefault(p => p.UserId == UserId);

            if (userProfile != null && userProfile.ProductBrand_ID > 0)
            {
                try
                {
                    //init param
                    var pProductBrandID = new SqlParameter("@pProductBrandID", userProfile.ProductBrand_ID);
                    var pCustomerFilter = new SqlParameter("@pCustomerFilter", CustomerFilter ?? (object)DBNull.Value);
                    var pPostFilter     = new SqlParameter("@pPostFilter", PostFilter ?? (object)DBNull.Value);
                    var pOrderFilter    = new SqlParameter("@pOrderFilter", OrderFilter ?? (object)DBNull.Value);
                    var pFinanceFilter  = new SqlParameter("@pFinanceFilter", FinanceFilter ?? (object)DBNull.Value);

                    var result = await HanomaContext.Set <GetDashBoard_Result>()
                                 .FromSqlRaw($"EXECUTE dbo.GetDashBoard "
                                             + $"@pProductBrandID = @pProductBrandID, "
                                             + $"@pCustomerFilter = @pCustomerFilter, "
                                             + $"@pPostFilter = @pPostFilter, "
                                             + $"@pOrderFilter = @pOrderFilter, "
                                             + $"@pFinanceFilter = @pFinanceFilter ", pProductBrandID, pCustomerFilter, pPostFilter, pOrderFilter, pFinanceFilter)
                                 .AsNoTracking()
                                 .ToListAsync();

                    return(result);
                }
                catch (Exception ex)
                {
                }
            }
            return(new List <GetDashBoard_Result>());
        }
Beispiel #9
0
        public async Task <ArticleSearchDTO> SearchArticle(string keyword, int?ArticleCategory_ID, int?ArticleTypeId, int?page, int?PageSize)
        {
            var output              = new ArticleSearchDTO();
            var pKeyword            = new SqlParameter("@Keyword", keyword);
            var pArticleCategory_ID = new SqlParameter("@ArticleCategory_ID", ArticleCategory_ID ?? (object)DBNull.Value);
            var pArticleTypeId      = new SqlParameter("@ArticleType_ID", ArticleTypeId ?? (object)DBNull.Value);
            var pPage        = new SqlParameter("@CurrentPage", page ?? 1);
            var pPageSize    = new SqlParameter("@PageSize", PageSize ?? 10);
            var pActiveCount = new SqlParameter("@ActiveCount", SqlDbType.Int)
            {
                Direction = ParameterDirection.Output
            };
            var pDeActiveCount = new SqlParameter("@DeActiveCount", SqlDbType.Int)
            {
                Direction = ParameterDirection.Output
            };
            var pItemCount = new SqlParameter("@ItemCount", SqlDbType.Int)
            {
                Direction = ParameterDirection.Output
            };

            //var pExceptionArticleID = new SqlParameter("@ExceptionArticle_ID", ArticleCategory_ID ?? (object)DBNull.Value);
            output.Data = await HanomaContext.Set <Article_Search_Result>()
                          .FromSqlRaw(
                $"EXECUTE dbo.Article_Search_Mobile @Keyword = @Keyword, @ArticleCategory_ID = @ArticleCategory_ID,  @ArticleType_ID = @ArticleType_ID,@CurrentPage = @CurrentPage,@PageSize = @PageSize,@ActiveCount = @ActiveCount out, @DeActiveCount = @DeActiveCount out, @ItemCount = @ItemCount out",
                pKeyword, pArticleCategory_ID, pArticleTypeId, pPage, pPageSize, pActiveCount, pDeActiveCount, pItemCount)
                          .AsNoTracking()
                          .ToListAsync();

            output.CurrentPage = page ?? 1;
            output.PageSize    = PageSize ?? 10;
            output.TotalRecord = (int)pItemCount.Value;
            output.TotalPage   = (int)pActiveCount.Value;
            return(output);
        }
Beispiel #10
0
        public async Task AddNewFCMMessage(FCMMessage model)
        {
            FCMMessage item = new FCMMessage();

            item = model;
            HanomaContext.Add(item);
            await HanomaContext.SaveChangesAsync();
        }
Beispiel #11
0
        public Task UpdateData(FCMMessage Content)
        {
            //FCMMessage CurrentFCMMessage = HanomaContext.FCMMessage.FirstOrDefault(p => p.FCMMessage_ID == FCMMessage_ID);
            FCMMessage CurrentFCMMessage = new FCMMessage();

            CurrentFCMMessage.Title            = Content.Title;
            CurrentFCMMessage.Body             = Content.Body;
            CurrentFCMMessage.Content          = Content.Content;
            CurrentFCMMessage.UserName         = "";
            CurrentFCMMessage.UserID           = Content.UserID;
            CurrentFCMMessage.NotificationType = Content.NotificationType;
            CurrentFCMMessage.Form_ID          = Content.Form_ID;
            CurrentFCMMessage.ParameterId      = Content.ParameterId ?? 0;
            CurrentFCMMessage.FullUrl          = Content.FullUrl;
            CurrentFCMMessage.Topic            = Content.Topic;
            CurrentFCMMessage.CreateDate       = DateTime.Now;
            CurrentFCMMessage.CreateBy         = Content.UserID;
            CurrentFCMMessage.UserID           = Content.UserID;
            HanomaContext.FCMMessage.Add(CurrentFCMMessage);
            HanomaContext.SaveChangesAsync();


            //Insert FCMMessageToken
            //if (Content.Topic == "Global")
            //{
            //    var ItemClient = HanomaContext.FCMClient.Select(p => p.UserID).Distinct().ToList();
            //    foreach (var p in ItemClient)
            //    {
            //        FCMMessageForTokken item = new FCMMessageForTokken();
            //        if (p != null) item.UserID = p.Value;
            //        item.FCMMessage_ID = CurrentFCMMessage.FCMMessage_ID;
            //        item.CreateBy = Guid.Parse(User_ID);
            //        item.CreateDate = DateTime.Now;
            //        HanomaContext.FCMMessageForTokken.Add(item);
            //        HanomaContext.SaveChangesAsync();
            //    }
            //}
            //else
            //{
            //    var ItemClient = HanomaContext.FCMClient.Where(p => p.Topic == Content.Topic).Select(i => i.UserID).Distinct().ToList();
            //    if (ItemClient != null)
            //    {
            //        foreach (var p in ItemClient)
            //        {
            //            FCMMessageForTokken item = new FCMMessageForTokken();
            //            if (p != null) item.UserID = p.Value;
            //            item.FCMMessage_ID = CurrentFCMMessage.FCMMessage_ID;
            //            item.CreateBy = Guid.Parse(User_ID);
            //            item.CreateDate = DateTime.Now;
            //            HanomaContext.FCMMessageForTokken.Add(item);
            //            HanomaContext.SaveChangesAsync();
            //        }
            //    }
            //}

            return(Task.CompletedTask);
        }
Beispiel #12
0
        public async Task UpdateImgBannerProductBrand(string fileName, int ProductBrandId)
        {
            var prodBrand = HanomaContext.ProductBrand.Find(ProductBrandId);

            if (prodBrand != null)
            {
                prodBrand.Banner = fileName;
                HanomaContext.SaveChanges();
            }
        }
Beispiel #13
0
        public int AddNewData(string UserID)
        {
            FCMMessage CurrentFCMMessage = new FCMMessage();

            CurrentFCMMessage.CreateDate = DateTime.Now;
            CurrentFCMMessage.CreateBy   = Guid.Parse(UserID);
            HanomaContext.FCMMessage.Add(CurrentFCMMessage);
            HanomaContext.SaveChangesAsync();
            return(CurrentFCMMessage.FCMMessage_ID);
        }
Beispiel #14
0
        public async Task UpgradePackageBrand(int ProductBrandId, int ProductBrandTypeId)
        {
            var prodBrand = HanomaContext.ProductBrand.Find(ProductBrandId);

            if (prodBrand != null)
            {
                prodBrand.ProductBrandType_ID = ProductBrandTypeId;
                HanomaContext.SaveChanges();
            }
        }
Beispiel #15
0
 public ProductController(IRepositoryWrapper repoWrapper, ILoggerManager logger, IMapper mapper, HanomaContext _hanomaContext, IDistributedCache distributedCache, IPaymentRepositoryWrapper repoPaymentWrapper, IConfiguration configuration)
 {
     hanomaContext       = _hanomaContext;
     _repoWrapper        = repoWrapper;
     _logger             = logger;
     _mapper             = mapper;
     _distributedCache   = distributedCache;
     _repoPaymentWrapper = repoPaymentWrapper;
     _configuration      = configuration;
 }
Beispiel #16
0
        public async Task UpdateImgLogoLibrary(string fileName, int LibraryId)
        {
            var lib = HanomaContext.Library.Find(LibraryId);

            if (lib != null)
            {
                lib.Image = fileName;
                HanomaContext.SaveChanges();
            }
        }
Beispiel #17
0
        public async Task <List <GetArticleHome_Result> > GetArtByCateHome(string keyword)
        {
            var pKeyword = new SqlParameter("@Keyword", keyword);

            return(await HanomaContext.Set <GetArticleHome_Result>()
                   .FromSqlRaw(
                       $"EXECUTE dbo.GetArticleHome @Keyword = @Keyword",
                       pKeyword)
                   .AsNoTracking()
                   .ToListAsync());
        }
Beispiel #18
0
        public void CreateNewUserProfile(string userId, string Email, string Phone = null, int?accountType = 1)
        {
            try
            {
                var profileExist = HanomaContext.AspNetUserProfiles.FirstOrDefault(x => x.UserId.Equals(userId));
                if (profileExist != null)
                {
                    return;
                }


                var regtype = String.IsNullOrEmpty(Phone) ? "Email" : "Phone";
                if (regtype == "Email")
                {
                    //SendEmailToCEO(userId, Email);
                }
                else
                {
                    //SendEmailToCEO(userId, Phone);
                }

                var roles           = HanomaContext.AspNetRoles.ToList();
                var productBrand_ID = 0;

                HanomaContext.AspNetUserRoles.Add(new AspNetUserRoles()
                {
                    UserId = userId,
                    RoleId = roles.FirstOrDefault(x => x.Name.Equals("Thành viên")).Id
                });


                var profilers = new AspNetUserProfiles
                {
                    UserId = userId,
                    //FullName = Email,
                    Phone            = Phone,
                    AccountType      = 1, //accountType ?? 1,
                    ProductBrand_ID  = productBrand_ID,
                    RegType          = regtype,
                    RegisterDate     = DateTime.Now,
                    LastActivityDate = DateTime.Now,
                    Rank             = 1,
                    Location_ID      = -1
                };

                var profile = HanomaContext.AspNetUserProfiles.Add(profilers);
                HanomaContext.SaveChanges();
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Beispiel #19
0
        public void UpdateFCMClient(Guid fcmClientId, FCMClient fcmClient)
        {
            var fcmClientItem = HanomaContext.FCMClient.Find(fcmClientId);

            if (fcmClientItem != null)
            {
                fcmClientItem.LastSeen = DateTime.Now;
                fcmClientItem.UserID   = fcmClient.UserID;
                fcmClientItem.UserName = fcmClient.UserName;
                fcmClientItem.Topic    = fcmClient.UserID.ToString();
                HanomaContext.SaveChanges();
            }
        }
Beispiel #20
0
 public void UpdateUserProfiler(string userId, int productBrandId)
 {
     try
     {
         var profiler = HanomaContext.AspNetUserProfiles.FirstOrDefault(x => x.UserId.Equals(userId));
         profiler.ProductBrand_ID = productBrandId;
         HanomaContext.SaveChanges();
     }
     catch (Exception exception)
     {
         //   log.Error(exception);
     }
 }
Beispiel #21
0
        public async Task <List <ProductHighLight_Search_Result> > GetSponsorProduct(int CategoryId, int?ProductTypeId, int Top)
        {
            var pProductCategoryId = new SqlParameter("@ProductCategory_ID", CategoryId);
            var pProductTypeId     = new SqlParameter("@ProductType_ID", ProductTypeId);

            var output = await HanomaContext.Set <ProductHighLight_Search_Result>()
                         .FromSqlRaw($"EXECUTE dbo.ProductHighLight_Search " +
                                     $"@ProductCategory_ID = @ProductCategory_ID, " +
                                     $"@ProductType_ID = @ProductType_ID ", pProductCategoryId, pProductTypeId)
                         .AsNoTracking()
                         .ToListAsync();

            return(output);
        }
Beispiel #22
0
 public void UpdateUrl(int libraryId)
 {
     try
     {
         var lib    = HanomaContext.Library.FirstOrDefault(x => x.Library_ID == libraryId);
         var urlNew = FormatURL(lib.Title) + "-" + lib.Library_ID.ToString();
         lib.URL = urlNew;
         HanomaContext.SaveChanges();
     }
     catch (Exception exception)
     {
         //log.Error(exception);
     }
 }
Beispiel #23
0
 public void UpdateUrlProductBrand(int productBrandId)
 {
     try
     {
         var productBrand = HanomaContext.ProductBrand.FirstOrDefault(x => x.ProductBrand_ID == productBrandId);
         var urlNew       = FormatURL(productBrand.Name) + "-" + productBrand.ProductBrand_ID.ToString();
         productBrand.URL = urlNew;
         HanomaContext.SaveChanges();
     }
     catch (Exception exception)
     {
         //log.Error(exception);
     }
 }
Beispiel #24
0
        public async Task <List <ProductBrand> > GetTopBrand(int topX)
        {
            var BlockName = new SqlParameter("@BlockName", "enterprise_reputation");

            var output = await HanomaContext.Set <ProductBrand>()
                         .FromSqlRaw($" SELECT TOP {topX} P.* FROM dbo.ProductBrand AS P WITH (NOLOCK)" +
                                     $" INNER JOIN dbo.ProductBrandBlockProductBrand AS BBP WITH(NOLOCK) ON BBP.ProductBrand_id = P.ProductBrand_ID" +
                                     $" INNER JOIN dbo.ProductBrandBlock AS BB WITH(NOLOCK) ON BBP.ProductBrandBlock_id = BB.ProductBrandBlock_id" +
                                     $" WHERE BB.Name = @BlockName", BlockName)
                         .AsNoTracking()
                         .ToListAsync();

            return(output);
        }
Beispiel #25
0
        public void CreateUserSocial(string LoginProvider, string ProviderKey, string UserId)
        {
            var checkExist = HanomaContext.AspNetUserLogins.FirstOrDefault(p =>
                                                                           p.LoginProvider == LoginProvider && p.ProviderKey == ProviderKey);

            if (checkExist == null)
            {
                AspNetUserLogins item = new AspNetUserLogins();
                item.LoginProvider = LoginProvider;
                item.ProviderKey   = ProviderKey;
                item.UserId        = UserId;
                HanomaContext.AspNetUserLogins.Add(item);
                HanomaContext.SaveChangesAsync();
            }
        }
Beispiel #26
0
        public async Task <bool> UpdateBrandReferralCode(int ProductBrandId, string ReferralCode)
        {
            var prodBrand = HanomaContext.ProductBrand.Find(ProductBrandId);

            if (prodBrand != null)
            {
                prodBrand.ReferralCode     = ReferralCode;
                prodBrand.ReferralCodeDate = DateTime.Now;
                HanomaContext.SaveChangesAsync();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #27
0
        public async Task <IEnumerable <Video_Search_Mobile_Result> > GetVideoByCate(int?VideoCategory_ID, int ArticleTypeId, int?page, int PageSize)
        {
            var pVideoCategory_ID = new SqlParameter("@VideoCategory_ID", VideoCategory_ID ?? (object)DBNull.Value);
            var pArticleTypeId    = new SqlParameter("@ArticleType_ID", ArticleTypeId);
            var pPage             = new SqlParameter("@CurrentPage", page ?? 1);
            var pPageSize         = new SqlParameter("@PageSize", PageSize);
            var pStatusTypeID     = new SqlParameter("@StatusType_ID", 4);

            var result = await HanomaContext.Set <Video_Search_Mobile_Result>()
                         .FromSqlRaw(
                $"EXECUTE dbo.Video_Search_Mobile @VideoCategory_ID=@VideoCategory_ID, @StatusType_ID = @StatusType_ID, @ArticleType_ID = @ArticleType_ID,@CurrentPage = @CurrentPage,@PageSize = @PageSize ",
                pVideoCategory_ID, pStatusTypeID, pArticleTypeId, pPage, pPageSize)
                         .AsNoTracking()
                         .ToListAsync();

            return(result);
        }
        public async Task <bool> DeleteDeliveryAddress(int Id, string UserId)
        {
            var pUserId = Guid.Parse(UserId);
            var item    = await HanomaContext.DeliveryAddress.FirstOrDefaultAsync(p => p.CreateBy == pUserId && p.Id == Id);

            if (item == null)
            {
                return(false);
            }
            else
            {
                HanomaContext.DeliveryAddress.Remove(item);
                await HanomaContext.SaveChangesAsync();

                return(true);
            }
        }
        public async Task <int> SubscriptionEmail(string email)
        {
            var result       = new Subscription();
            var subscription = await HanomaContext.Subscription.FirstOrDefaultAsync(x => x.Email.Equals(email));

            var model = new Subscription
            {
                Email      = email,
                CreateDate = DateTime.Now,
                Active     = true
            };
            await HanomaContext.Subscription.AddAsync(model);

            await HanomaContext.SaveChangesAsync();

            return(model.Subscription_ID);
        }
        public async Task <bool> PostShopingCartAction(ShoppingCartDetailDTO model)
        {
            var item = HanomaContext.ShoppingCartDetail.Find(model.Id);

            if (item != null)
            {
                item.StatusCart      = model.StatusCart;
                item.ReasonCancel    = model.ReasonCancel; // Lý do hủy
                item.IsCancelByBuyer = model.IsCancelByBuyer;
                item.LastEditBy      = Guid.Parse(model.UserId);
                item.LastEditDate    = DateTime.Now;
                await HanomaContext.SaveChangesAsync();
            }
            else
            {
                return(false);
            }
            return(true);
        }