예제 #1
0
        public async Task <ActionResult> LoadOffRequests()
        {
            try
            {
                var           AllReqs = (List <OfflinRequestModel>)(await _offreqrepo.GetAll()).Data;
                List <object> result  = new List <object>();
                Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fa");
                int i = 1;
                foreach (var item in AllReqs.OrderByDescending(x => (DateTime)x.Created_At))
                {
                    var user = await _userrepo.GetById(item.O_User);

                    result.Add(new {
                        id      = item.O_Id,
                        counter = i,
                        user    = (user != null) ? user.U_Name + " " + user.U_Family : "",
                        url     = item.O_Url,
                        detail  = item.O_Details,
                        price   = item.O_Price,
                        deliver = item.O_DeliverDate,
                        reqdate = ((DateTime)item.Created_At).ToString("yyyy/MM/dd HH:mm:ss"),
                        reason  = item.O_Reason,
                        status  = item.O_Status
                    });
                    i++;
                }
                return(new JsonResult(ResponseModel.Success(data: result)));
            }
            catch (Exception ex)
            {
                _logger.LogError("Error", ex);
                return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
            }
        }
        public async Task <IActionResult> Index()
        {
            var basket = await _basketservice.GetBasketItems(Request);

            foreach (var item in basket.CartItems)
            {
                item.Product.PriceModel = await _priceCalculator.CalculateBookPrice(item.Product.P_Id, _lang.GetLang());
            }
            ViewBag.CVRT    = 1000;
            ViewBag.BINPERC = 1;
            var cvrtbase = ((List <OptionsModel>)(await _optionrepository.GetAll()).Data).FirstOrDefault(x => x.O_Key == "CVRTTOMANTOPOINT");
            var bin      = ((List <OptionsModel>)(await _optionrepository.GetAll()).Data).FirstOrDefault(x => x.O_Key == "GIFTBINPERCENTAGE");

            if (bin != null)
            {
                ViewBag.BINPERC = int.Parse(bin.O_Value);
            }
            if (cvrtbase != null)
            {
                ViewBag.CVRT = int.Parse(cvrtbase.O_Value);
            }
            ViewBag.LoggedIn = TokenService.AuthorizeUser(Request) > 0;
            ViewBag.User     = await _userrepository.GetById(TokenService.AuthorizeUser(Request));

            return(View(basket));
        }
        public async Task <ActionResult> SetIndexSections(IndexSectionsModel ism)
        {
            try
            {
                IndexBoxInfoModel BoxInfo = ((List <IndexBoxInfoModel>)(await _indexboxinforepo.GetAll()).Data).FirstOrDefault(x => x.I_SecId == ism.Section && x.Lang == ism.Lang);

                if (BoxInfo == null)
                {
                    await _indexboxinforepo.Insert(new IndexBoxInfoModel()
                    {
                        I_SecId = ism.Section,
                        I_Title = ism.Title,
                        I_Icon  = ism.Icon,
                        I_Sort  = ism.Sort,
                        Lang    = ism.Lang
                    });

                    await _indexboxinforepo.CommitAllChanges();
                }
                else
                {
                    await _indexboxinforepo.Update(new IndexBoxInfoModel()
                    {
                        I_Id    = BoxInfo.I_Id,
                        I_SecId = ism.Section,
                        I_Title = ism.Title,
                        I_Icon  = ism.Icon,
                        I_Sort  = ism.Sort,
                        Lang    = ism.Lang
                    });

                    await _indexboxinforepo.CommitAllChanges();
                }
                List <IndexBoxProductRelModel> OldRelations = ((List <IndexBoxProductRelModel>)(await _indexsectionrepo.GetAll()).Data).Where(x => x.I_SecId == ism.Section && x.Lang == ism.Lang).ToList();
                foreach (var item in OldRelations)
                {
                    await _indexsectionrepo.Delete(item);
                }
                await _indexsectionrepo.CommitAllChanges();

                foreach (int p in ism.Products)
                {
                    await _indexsectionrepo.Insert(new IndexBoxProductRelModel()
                    {
                        Lang    = ism.Lang,
                        I_Pid   = p,
                        I_SecId = ism.Section
                    });
                }
                await _indexsectionrepo.CommitAllChanges();

                return(new JsonResult(ResponseModel.Success("اطلاعات با موفقیت ذخیره گردید")));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
예제 #4
0
        public async Task <IActionResult> GetSearch(string id)
        {
            string[] QueryStrings = id.Split(" ");
            var      AllProduct   = ((List <ProductModel>)(await _productrepo.GetAll()).Data).Where(x => x.P_Status && QueryStrings.Any(y => x.P_Title.Contains(y, StringComparison.InvariantCultureIgnoreCase) || x.P_Description.Contains(y, StringComparison.InvariantCultureIgnoreCase) || (x.P_BrandTitle != null && x.P_BrandTitle.Contains(y, StringComparison.InvariantCultureIgnoreCase)))).Take(8).ToList();

            ViewBag.search = id;
            if (AllProduct.Count() < 1)
            {
                return(Content("موردی یافت نشد"));
            }
            return(View(AllProduct));
        }
예제 #5
0
        public async Task <IActionResult> Index(int cat = 0, string title = null)
        {
            ViewBag.Category = ((List <NoticesCategoryModel>)(await _categoryrepo.GetAll()).Data).Where(x => x.NC_IsDeleted == false && x.NC_Status && x.NC_Type == 1).OrderBy(x => x.NC_SortField).ToList();

            var ProdCatList = (List <ProductCategoryModel>)(await _categories.GetAll()).Data;

            ProdCatList.Where(x => x.PC_ParentId == 0 && x.PC_Status && x.PC_IsDeleted != true).ToList();
            ViewBag.ProductCategory = ProdCatList;
            var AllNews = ((List <NoticesModel>)(await _noticesrepo.GetAll()).Data).Where(x => x.N_IsDeleted == false && x.N_Status && x.N_Type == 1).OrderBy(x => x.N_Sort).ToList();

            return(View(AllNews));
        }
예제 #6
0
 public async Task <IActionResult> LoadFaqCategory()
 {
     try
     {
         var allNotifies = ((List <FaqCategoryModel>)(await _faqcatrepo.GetAll()).Data).Where(x => x.F_IsDeleted == false).ToList();
         return(new JsonResult(ResponseModel.Success(data: allNotifies)));
     }
     catch (Exception ex)
     {
         return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
     }
 }
예제 #7
0
        public async Task Initilize()
        {
            var cvrtbase = ((List <OptionsModel>)(await _optionrepository.GetAll()).Data).FirstOrDefault(x => x.O_Key == "CVRTTOMANTOPOINT");
            var bin      = ((List <OptionsModel>)(await _optionrepository.GetAll()).Data).FirstOrDefault(x => x.O_Key == "GIFTBINPERCENTAGE");

            if (cvrtbase != null)
            {
                CVRT = int.Parse(cvrtbase.O_Value);
            }
            if (bin != null)
            {
                BINPERC = int.Parse(bin.O_Value);
            }
        }
        public async Task <IActionResult> Index()
        {
            try
            {
                ViewBag.category = null;
                List <ProductModel> items = new List <ProductModel>();
                string cookie             = "";
                HttpContext.Request.Cookies.TryGetValue("Compaire", out cookie);
                var ProdCatList = (List <ProductCategoryModel>)(await _categories.GetAll()).Data;
                ViewBag.ProductCategory = ProdCatList.Where(x => x.PC_ParentId == 0 && x.PC_Status).ToList();

                if (cookie != null)
                {
                    var decryptCookie      = Barayand.Common.Services.CryptoJsService.DecryptStringAES(cookie);
                    CompareCookieModel ccm = JsonConvert.DeserializeObject <CompareCookieModel>(decryptCookie);


                    foreach (var item in ccm.Products)
                    {
                        var p = await _productrepo.GetById(item);

                        items.Add(p);
                    }
                }
                if (items.Count() > 0)
                {
                    var getAllProductByCatId = ((List <ProductModel>)(await _productrepo.GetAll()).Data).Where(x => x.P_EndLevelCatId == items.FirstOrDefault().P_EndLevelCatId).ToList();
                    foreach (var item in items)
                    {
                        getAllProductByCatId.Remove(item);
                    }
                    ViewBag.getAllProductByCatId = getAllProductByCatId;
                    #region Brand
                    var BrandGroups = getAllProductByCatId.GroupBy(x => x.P_BrandId)?.Select(x => x.FirstOrDefault().P_BrandId).ToList();
                    ViewBag.Brands = ((List <BrandModel>)(await _brandrepo.GetAll()).Data).Where(x => BrandGroups.Contains(x.B_Id)).ToList();
                    #endregion
                }
                else
                {
                    ViewBag.Brands = ((List <BrandModel>)(await _brandrepo.GetAll()).Data).Where(x => x.B_Status).ToList();
                }
                return(View(items));
            }
            catch (Exception ex)
            {
                return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
            }
        }
예제 #9
0
        public async Task <IActionResult> LoadImagesByCat(int cat, int page = 1, string title = null)
        {
            try
            {
                var existsGCat = await _gallerycatrepo.GetById(cat);

                if (existsGCat == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                ViewBag.PageSeo = existsGCat.GC_Seo;
                var galleris  = ((List <ImageGalleryModel>)(await _imagerepo.GetAll()).Data).Where(x => x.IG_Status && x.IG_CatId == cat && x.Lang == _lang.GetLang()).OrderBy(x => x.IG_SortField).ToList();
                int pageSize  = 10;
                int totalPage = (int)Math.Ceiling((double)galleris.Count() / pageSize);
                galleris = galleris.Skip((page - 1) * pageSize).Take(pageSize).ToList();

                ViewBag.CurrentPage = page;
                ViewBag.TotalPages  = totalPage;
                ViewBag.Cat         = cat;
                return(View(galleris));
            }
            catch (Exception ex)
            {
                _logger.LogError("ErrorGalleryController", ex);
                return(View(new List <ImageGalleryModel>()));
            }
        }
예제 #10
0
 public async Task <IActionResult> Index(bool isajax, int page = 1)
 {
     try
     {
         var brand = ((List <BrandModel>)(await _brandrepo.GetAll()).Data).Where(x => x.B_Status && !x.B_IsDeleted).OrderBy(x => x.B_SortField).ToList();
         if (brand != null)
         {
             #region Paging
             Paging paging = new Paging();
             paging.TotalCount  = brand.Count();
             paging.PageSize    = 24;
             paging.CurrentPage = page;
             paging.TotalPages  = (int)Math.Ceiling(paging.TotalCount / (double)paging.PageSize);
             ViewBag.paging     = paging;
             #endregion
             var items = brand.Skip((paging.CurrentPage - 1) * paging.PageSize).Take(paging.PageSize).ToList();
             if (isajax)
             {
                 return(View("_brandlist", items));
             }
             return(View(items));
         }
         return(RedirectToAction("Index", "Home"));
     }
     catch (Exception ex)
     {
         _logger.LogError("Brands", ex);
         return(RedirectToAction("Index", "Home"));
     }
 }
예제 #11
0
        public async Task <ActionResult> GetAllAttrsByCat(int catid)
        {
            try
            {
                CatAttrRelationRepository carr = new CatAttrRelationRepository(new DAL.Context.BarayandContext(null));
                var catattrs = ((List <CatAttrRelationModel>)(await _repository.GetAll()).Data).Where(x => x.X_IsDeleted == false && x.X_Status && x.X_CatId == catid).ToList();
                List <AttributeModel> data = ((List <AttributeModel>)(await _attrs.GetAll()).Data);
                List <object>         Data = new List <object>();

                foreach (var item in catattrs)
                {
                    var attribute = data.FirstOrDefault(x => x.A_Id == item.X_AttrId);
                    if (attribute != null)
                    {
                        Data.Add(new
                        {
                            A_Title    = attribute.A_Title,
                            A_Id       = attribute.A_Id,
                            A_Status   = item.X_Status,
                            relationId = item.X_Id,
                        });
                    }
                }
                return(new JsonResult(ResponseModel.Success(data: Data)));
            }
            catch (Exception ex)
            {
                return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
            }
        }
예제 #12
0
        public async Task <IActionResult> VideoGalleryVideos(int cat = 0, int page = 1, string title = null)
        {
            try
            {
                var galleris   = ((List <VideoGalleryModel>)(await _videorepo.GetAll()).Data).Where(x => x.VG_Status && x.VG_IsDeleted == false).OrderBy(x => x.VG_SortField).ToList();
                var existsGCat = await _gallerycatrepo.GetById(cat);

                if (existsGCat != null)
                {
                    galleris        = galleris.Where(x => x.VG_CatId == cat).ToList();
                    ViewBag.PageSeo = existsGCat.GC_Seo;
                }

                int pageSize  = 10;
                int totalPage = (int)Math.Ceiling((double)galleris.Count() / pageSize);

                ViewBag.CurrentPage = page;
                ViewBag.TotalPages  = totalPage;
                ViewBag.Cat         = cat;
                ViewBag.Categories  = ((List <GalleryCategoryModel>)(await _gallerycatrepo.GetAll()).Data).Where(x => x.GC_Status && x.GC_Type == 2 && x.Lang == _lang.GetLang()).OrderBy(x => x.GC_SortField).ToList();
                return(View(galleris));
            }
            catch (Exception ex)
            {
                _logger.LogError("ErrorGalleryController", ex);
                return(View(new List <GalleryCategoryModel>()));
            }
        }
예제 #13
0
        public async Task CheckOptions()
        {
            var  opt      = ((List <OptionsModel>)(await _optionrepo.GetAll()).Data).FirstOrDefault(x => x.O_Key == "DELETEDISCOUNTS");
            bool isActive = bool.Parse(opt.O_Value);

            this.RemoveDiscounts = isActive;
        }
예제 #14
0
        public async Task <bool> UserAccessProductFile(int pid, int userid)
        {
            try
            {
                List <OrderModel>   orders   = ((List <OrderModel>)(await _Orderrepo.GetAll()).Data);
                List <InvoiceModel> invoices = ((List <InvoiceModel>)(await _invoicerepo.GetAll()).Data);

                List <InvoiceModel> userInvoices = invoices.Where(x => x.I_UserId == userid && x.I_Status > 0).ToList();
                if (userInvoices.Count < 1)
                {
                    return(false);
                }
                foreach (var i in userInvoices)
                {
                    if (orders.Count(x => x.O_ReciptId == i.I_Id && x.O_ProductId == pid) > 0)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
예제 #15
0
        public async Task <IActionResult> Profile()
        {
            try
            {
                var authorize = Barayand.Common.Services.TokenService.AuthorizeUser(Request);
                if (authorize < 1)
                {
                    if (authorize == 0)
                    {
                        Response.Cookies.Delete("HomeKitoUser");
                    }
                    return(RedirectToAction("Index", new { redirect = "/User/Profile" }));
                }

                UserModel userModel = await _repository.GetById(authorize);

                if (userModel == null)
                {
                    return(RedirectToAction("Index", new { redirect = "/User/Profile" }));
                }
                List <InvoiceModel> invoices = ((List <InvoiceModel>)(await _invoicerepository.GetAll()).Data);
                invoices = (invoices != null) ? invoices.Where(x => x.I_Status > 0 && x.I_UserId == authorize).ToList() : null;
                List <InvoiceModel> FivaLastInvoices = new List <InvoiceModel>();

                List <OfflinRequestModel> OfflineRequests = ((List <OfflinRequestModel>)(await _offreqrepository.GetAll()).Data).Where(x => x.O_User == authorize).ToList();
                if (invoices != null)
                {
                    FivaLastInvoices = invoices.Take(5).ToList();
                }
                else
                {
                    FivaLastInvoices = null;
                }
                ViewBag.Favorites = await _favoritrepostory.GetByUser(authorize);

                ViewBag.WalletHistory = await _walletrepository.GetAllUserTransactions(authorize);

                ViewBag.LastInvoices    = FivaLastInvoices;
                ViewBag.UserInvoices    = invoices;
                ViewBag.OfflineRequests = OfflineRequests;
                return(View(userModel));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
예제 #16
0
        public async Task <List <PromotionBoxModel> > GetByType(int Type)
        {
            try
            {
                var  opt      = ((List <OptionsModel>)(await _optionrepo.GetAll()).Data).FirstOrDefault(x => x.O_Key == "DELETEDISCOUNTS");
                bool isActive = bool.Parse(opt.O_Value);

                var  optSpecial      = ((List <OptionsModel>)(await _optionrepo.GetAll()).Data).FirstOrDefault(x => x.O_Key == "SPECIALSALESTATE");
                bool isActiveSpecial = bool.Parse(optSpecial.O_Value);
                var  AllPromotions   = ((List <PromotionBoxModel>)(await GetAll()).Data).Where(x => x.B_Type == Type).ToList();
                if ((isActive && Type == 6))
                {
                    return(null);
                }
                if ((!isActiveSpecial && Type == 6))
                {
                    return(null);
                }
                foreach (var box in AllPromotions)
                {
                    foreach (var item in _context.PromotionBoxProducts.Where(x => x.X_SectionId == box.B_SectionId))
                    {
                        var p = _context.Product.FirstOrDefault(x => x.P_Id == item.X_ProdId);
                        if (Type == 6)
                        {
                            p.P_Title = item.X_ProdTitle;
                        }
                        var combine = _context.ProductCombine.FirstOrDefault(x => x.X_ColorId == item.X_ColorId && x.X_WarrantyId == item.X_WarrantyId && x.X_ProductId == item.X_ProdId);
                        if (combine != null)
                        {
                            combine.PriceModel = await _pcalcrepo.CalculateProductCombinePrice(combine.X_Id, p.P_EndLevelCatId);

                            p.DefaultProductCombine = combine;
                            if (p != null)
                            {
                                box.Products.Add(p);
                            }
                        }
                    }
                }
                return(AllPromotions);
            }
            catch (Exception ex)
            {
                return(new List <PromotionBoxModel>());
            }
        }
예제 #17
0
 public async Task <IActionResult> Index(int page = 1)
 {
     try
     {
         var galleris  = ((List <GalleryCategoryModel>)(await _gallerycatrepo.GetAll()).Data).Where(x => x.GC_Status && x.GC_Type == 1 && x.GC_IsDeleted == false && x.Lang == _lang.GetLang()).OrderBy(x => x.GC_SortField).ToList();
         int pageSize  = 10;
         int totalPage = (int)Math.Ceiling((double)galleris.Count() / pageSize);
         galleris            = galleris.Skip((page - 1) * pageSize).Take(pageSize).ToList();
         ViewBag.CurrentPage = page;
         ViewBag.TotalPages  = totalPage;
         return(View(galleris));
     }
     catch (Exception ex)
     {
         _logger.LogError("ErrorGalleryController", ex);
         return(View(new List <GalleryCategoryModel>()));
     }
 }
예제 #18
0
 public async Task <ActionResult> LoadProvinces()
 {
     try
     {
         return(new JsonResult(await _provincerepo.GetAll()));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
예제 #19
0
 public async Task <ActionResult> UpdateOption(OptionsModel om)
 {
     try
     {
         var option = ((List <OptionsModel>)(await _optionrepo.GetAll()).Data).FirstOrDefault(x => x.O_Key == om.O_Key);
         if (option == null)
         {
             return(new JsonResult(await _optionrepo.Insert(om)));
         }
         else
         {
             option.O_Value = om.O_Value;
             return(new JsonResult(await _optionrepo.Update(option)));
         }
     }
     catch (Exception ex)
     {
         _logger.LogError("Error in options controller", ex);
         return(new JsonResult(ResponseModel.Error(data: ex)));
     }
 }
예제 #20
0
 public async Task <ActionResult> LoadDepartments(string lang = "")
 {
     try
     {
         var deps = ((List <DepartmentModel>)(await _departmentrepo.GetAll()).Data).Where(x => x.Lang == lang).ToList();
         return(new JsonResult(ResponseModel.Success(data: deps)));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
예제 #21
0
 public async Task <IActionResult> ContactUs(string title = "")
 {
     try
     {
         var page = ((List <DynamicPagesContent>)(await _dynamicrepeo.GetAll()).Data).FirstOrDefault(x => x.PageName == "ContactUs");
         if (page == null)
         {
             return(RedirectToAction("Index", "Home"));
         }
         ViewBag.PageSeo = page.PageSeo;
         ViewBag.Data    = JsonConvert.DeserializeObject <ContactUsData>(page.PageOtherSetting);
         var seo = Barayand.Common.Services.UtilesService.ParseSeoData(page.PageSeo);
         ViewBag.PGNAME = seo.title;
         return(View(page));
     }
     catch (Exception ex)
     {
         _logger.LogError("Error in main controller action index", ex);
         return(null);
     }
 }
예제 #22
0
 public async Task <IActionResult> LoadHeaderNotifies()
 {
     try
     {
         var allNotifies = ((List <HeaderNotificationModel>)(await _headernotifyrepo.GetAll()).Data);
         return(new JsonResult(ResponseModel.Success(data: allNotifies)));
     }
     catch (Exception ex)
     {
         return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
     }
 }
예제 #23
0
        public async Task Initilize()
        {
            var storeisactive       = ((List <OptionsModel>)(await _optionrepository.GetAll()).Data).FirstOrDefault(x => x.O_Key == "SHOPSTATE");
            var deletediscounts     = ((List <OptionsModel>)(await _optionrepository.GetAll()).Data).FirstOrDefault(x => x.O_Key == "DELETEDISCOUNTS");
            var isactivespecialsale = ((List <OptionsModel>)(await _optionrepository.GetAll()).Data).FirstOrDefault(x => x.O_Key == "SPECIALSALESTATE");

            if (storeisactive != null)
            {
                STOREISACTIVE = (storeisactive.O_Value == "true") ? true : false;
            }
            if (deletediscounts != null)
            {
                DELETEDISCOUNTS = (deletediscounts.O_Value == "true") ? true : false;
            }
            if (isactivespecialsale != null)
            {
                ISACTIVESPECIALSALE = (isactivespecialsale.O_Value == "true") ? true : false;
            }

            AllProducts = ((List <ProductCombineModel>)(await _productcombinerepo.GetAll()).Data);
        }
예제 #24
0
 public async Task <ActionResult> LoadServices(int type = 1)
 {
     try
     {
         var deps = ((List <ServiceModel>)(await _servicerepo.GetAll()).Data).Where(x => x.S_Type == type).ToList();
         return(new JsonResult(ResponseModel.Success(data: deps)));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
예제 #25
0
        public async Task <ResponseStructure> UseCoppon(HttpRequest httpRequest, HttpResponse httpResponse)
        {
            try
            {
                StringValues data;
                if (!httpRequest.Headers.TryGetValue("CouponInfo", out data))
                {
                    return(ResponseModel.Error("Invalid access detect."));
                }
                var        dec    = Barayand.Common.Services.CryptoJsService.DecryptStringAES(data);
                BasketItem rm     = JsonConvert.DeserializeObject <BasketItem>(dec);
                var        coppon = ((List <CopponModel>)(await _couponrepo.GetAll()).Data).FirstOrDefault(x => x.CP_Code == rm.CopponCode);
                if (coppon == null)
                {
                    return(ResponseModel.Error("Coppon code is invalid."));
                }
                if (DateTime.Now >= coppon.CP_EndDate || DateTime.Now < coppon.CP_StartDate)
                {
                    return(ResponseModel.Error("Coppon has been expired."));
                }
                BasketModel basket = new BasketModel();
                string      cookie;
                if (httpRequest.Cookies.TryGetValue("Cart", out cookie))
                {
                    if (cookie != null)
                    {
                        var basketInfo = Barayand.Common.Services.CryptoJsService.DecryptStringAES(cookie);
                        basket = JsonConvert.DeserializeObject <BasketModel>(basketInfo);
                        if (basket.Coppon.Count > 0)
                        {
                            return(ResponseModel.Error("Coppon was applied before."));
                        }
                        if (basket.Coppon.Count(x => x.CP_Code == coppon.CP_Code) > 0)
                        {
                            return(ResponseModel.Error("Coppon was applied before."));
                        }
                        basket.Coppon.Add(coppon);
                    }
                }

                string token = Barayand.Common.Services.CryptoJsService.EncryptStringToAES(JsonConvert.SerializeObject(basket));
                httpResponse.Cookies.Delete("Cart");
                httpResponse.Cookies.Append("Cart", token);
                return(ResponseModel.Success("Product added."));

                return(ResponseModel.Success());
            }
            catch (Exception ex)
            {
                _logger.LogError("Error in adding coupon to customer basket", ex);
                return(ResponseModel.ServerInternalError(data: ex));
            }
        }
예제 #26
0
        public async Task <IActionResult> LoadOrderProducts(string oid)
        {
            try
            {
                var authorize = Barayand.Common.Services.TokenService.AuthorizeUser(Request);
                if (authorize < 1)
                {
                    if (authorize == 0)
                    {
                        Response.Cookies.Delete("GbookUser");
                    }
                    return(new JsonResult(ResponseModel.Error("Your login token has expired.", new { EXPIREDTOKEN = true })));
                }
                var           orders   = ((List <OrderModel>)(await _orderrepository.GetAll()).Data).Where(x => x.O_ReciptId == oid);
                var           rinfo    = ((List <InvoiceModel>)(await _invoicerepository.GetAll()).Data).FirstOrDefault(x => x.I_Id == oid);
                List <object> Products = new List <object>();
                bool          hasHcopy = false;
                int           i        = 1;
                foreach (var item in orders)
                {
                    var prd = await _productrepository.GetById(item.O_ProductId);

                    Products.Add(new {
                        counter  = i,
                        prodname = prd.P_Title,
                        quantity = item.O_Quantity + " عدد",
                        total    = rinfo.I_TotalProductAmount,
                        price    = item.O_Price,
                        version  = (item.O_Version == 1)? "PDF":"HCOPY",
                        downlink = prd.P_DownloadLink
                    });
                    i++;
                    if (item.O_Version == 2)
                    {
                        hasHcopy = true;
                    }
                }
                var reciverinfo = "";
                if (hasHcopy)
                {
                    if (rinfo != null)
                    {
                        reciverinfo = rinfo.I_RecipientInfo;
                    }
                }
                return(new JsonResult(ResponseModel.Success(data: new { hashcopy = hasHcopy, recieptinfo = reciverinfo, products = Products })));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
예제 #27
0
 public async Task <ActionResult> GetPageContent(OutModels.Models.DynamicPages page)
 {
     try
     {
         var dynamicPages = (List <DynamicPagesContent>)(await _repository.GetAll()).Data;
         var data         = dynamicPages.FirstOrDefault(x => x.PageName == page.PageName && page.Lang == x.Lang);
         return(new JsonResult(ResponseModel.Success(data: data)));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
예제 #28
0
        public async Task <ResponseStructure> UseCoppon(HttpRequest httpRequest, HttpResponse httpResponse)
        {
            try
            {
                StringValues data;
                if (!httpRequest.Headers.TryGetValue("CouponInfo", out data))
                {
                    return(ResponseModel.Error("Invalid access detect."));
                }
                var dec = Barayand.Common.Services.CryptoJsService.DecryptStringAES(data);
                FullPropertyBasketItem rm = JsonConvert.DeserializeObject <FullPropertyBasketItem>(dec);
                var coppon = ((List <CopponModel>)(await _couponrepo.GetAll()).Data).FirstOrDefault(x => x.CP_Code == rm.CopponCode);
                if (coppon == null)
                {
                    return(ResponseModel.Error("کد تخفیف نامعتبر است."));
                }
                if (DateTime.Now >= coppon.CP_EndDate || DateTime.Now < coppon.CP_StartDate)
                {
                    return(ResponseModel.Error("کد تخفیف منقضی شده است."));
                }
                FullPropertyBasketModel basket = new FullPropertyBasketModel();
                string cookie;
                if (httpRequest.Cookies.TryGetValue("Cart", out cookie))
                {
                    if (cookie != null)
                    {
                        var basketInfo = Barayand.Common.Services.CryptoJsService.DecryptStringAES(cookie);
                        basket = JsonConvert.DeserializeObject <FullPropertyBasketModel>(basketInfo);
                        if (basket.Coppon.Count > 0)
                        {
                            return(ResponseModel.Error("بیشتر از یک کد تخفیف نمیتوانید استفاده نمایید"));
                        }
                        if (basket.Coppon.Count(x => x.CP_Code == coppon.CP_Code) > 0)
                        {
                            return(ResponseModel.Error("کد تخفیف قبلا اعمال شده است"));
                        }
                        basket.Coppon.Add(coppon);
                    }
                }

                string token = Barayand.Common.Services.CryptoJsService.EncryptStringToAES(JsonConvert.SerializeObject(basket));
                httpResponse.Cookies.Delete("Cart");
                httpResponse.Cookies.Append("Cart", token);
                return(ResponseModel.Success("کد تخفیف با موفقیت اعمال گردید"));
            }
            catch (Exception ex)
            {
                _logger.LogError("Error in adding coupon to customer basket", ex);
                return(ResponseModel.ServerInternalError(data: ex));
            }
        }
예제 #29
0
 public async Task <ActionResult> LoadStates(int prov = 0)
 {
     try
     {
         var AllStates = ((List <States>)(await _staterepo.GetAll()).Data);
         if (prov != 0)
         {
             AllStates = AllStates.Where(x => x.Province == prov).ToList();
         }
         return(new JsonResult(ResponseModel.Success(data: AllStates)));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
예제 #30
0
        public async Task <JsonResult> GetPriceAjax(int id, int garanty, int color)
        {
            try
            {
                var product = ((List <ProductCombineModel>)(await _Combine.GetAll()).Data).FirstOrDefault(x => x.X_ColorId == color && x.X_WarrantyId == garanty && x.X_ProductId == id && x.X_IsDeleted != true && x.X_Status);

                return(new JsonResult(ResponseModel.Success(data: new
                {
                    price = product.X_Price,
                    discounted = product.CalculatedPrice()
                })));
            }
            catch (Exception ex)
            {
                return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
            }
        }