public IActionResult GetCustomerRateList()
        {
            try
            {
                var res = _repository.ProductCustomerRate
                          .FindByCondition(c => c.Ddate == null && c.DaDate == null && c.Pid == null)
                          .Include(c => c.Product)
                          .Include(c => c.Customer)
                          .Include(c => c.FinalStatus)
                          .Select(c => new
                {
                    c.Id,
                    c.Rate,
                    c.CommentDesc,
                    CommentDate   = DateTimeFunc.TimeTickToMiladi(c.CommentDate.Value),
                    ProductName   = c.Product.Name,
                    ProductCoding = c.Product.Coding,
                    CustomerName  = c.Customer.Name + " " + c.Customer.Fname,
                    c.FinalStatusId,
                    Status = c.FinalStatus.Name
                }).ToList();

                _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
                return(Ok(res));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod());
                return(BadRequest(e.Message));
            }
        }
Example #2
0
 public IActionResult GetOfferList()
 {
     try
     {
         var res = _repository.Offer.FindByCondition(c => c.Ddate == null)
                   .Include(c => c.OfferType)
                   .Include(c => c.ProductOffer).ThenInclude(c => c.Product)
                   .Select(c => new
         {
             c.Id,
             c.Name,
             FromDate = DateTimeFunc.TimeTickToMiladi(c.FromDate.Value),
             ToDate   = DateTimeFunc.TimeTickToMiladi(c.ToDate.Value),
             c.MaximumPrice,
             c.Value,
             c.Description,
             Type        = c.OfferType.Name,
             Status      = c.DaDate == null ? "فعال" : "غیرفعال",
             ProductList = c.ProductOffer.Select(x => string.Join('-', x.Product.Name)).FirstOrDefault()
         }).OrderByDescending(c => c.Id).ToList();
         _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
         return(Ok(res));
     }
     catch (Exception e)
     {
         _logger.LogError(e, MethodBase.GetCurrentMethod());
         return(BadRequest(e.Message));
     }
 }
Example #3
0
 public void Delete(TEntity obj)
 {
     try
     {
         _dbSet.Remove(obj);
     }
     catch (Exception ex)
     {
         _log.LogError(ex.Message);
     }
 }
Example #4
0
        public IActionResult InsertSellerBio(string input)
        {
            try
            {
                var userId   = ClaimPrincipalFactory.GetUserId(User);
                var sellerId = _repository.Seller.GetSellerIdByUserId(userId);
                if (sellerId == 0)
                {
                    throw new BusinessException(XError.AuthenticationErrors.NotHaveRequestedRole());
                }

                var sellerComment = new SellerComment
                {
                    FinalStatusId = 37,
                    Cdate         = DateTime.Now.Ticks,
                    CuserId       = userId,
                    CommentType   = 1,
                    SellerId      = sellerId,
                    Comment       = input
                };


                _repository.SellerComment.Create(sellerComment);
                _repository.Save();

                _logger.LogData(MethodBase.GetCurrentMethod(), General.Results_.SuccessMessage(), null, input);
                return(Ok(General.Results_.SuccessMessage()));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod(), input);
                return(BadRequest(e.Message));
            }
        }
 public IActionResult GetCountryList()
 {
     try
     {
         var res = _repository.Location.FindByCondition(c => c.Ddate == null && c.DaDate == null && c.Pid == null).Select(c => new { c.Id, c.Name, c.LocationCode }).ToList();
         _logger.LogData(MethodBase.GetCurrentMethod(), res, null, res);
         return(Ok(res));
     }
     catch (Exception e)
     {
         _logger.LogError(e, MethodBase.GetCurrentMethod());
         return(BadRequest(e.Message));
     }
 }
Example #6
0
        public List <Stock> GetAllStocks()
        {
            var list = new List <Stock>();

            try
            {
                list = _dbStock.GetAll().ToList();
            }
            catch (Exception ex)
            {
                _log.LogError(ex.Message);
                throw ex;
            }
            return(list);
        }
 public IActionResult GetFamousCommentsList()
 {
     try
     {
         var res = _repository.Seller.FindByCondition(c => c.DaDate == null && c.Ddate == null)
                   .ToList();
         _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
         return(Ok(res));
     }
     catch (Exception e)
     {
         _logger.LogError(e, MethodBase.GetCurrentMethod());
         return(BadRequest(e.Message));
     }
 }
        public async Task ProcessPurchases()
        {
            try
            {
                _logHandler.LogInfo("Looking for purchases...");
                var purchases = await _repo.GetData();

                if (!purchases.List.Any())
                {
                    _logHandler.LogInfo("No purchases found!");
                    return;
                }
                else
                {
                    _logHandler.LogInfo("Purchases found!");
                }


                var generatedReceipts = new List <IReceipt>();
                foreach (var purchase in purchases.List)
                {
                    var receipt = await _calculator.Compute(purchase);

                    generatedReceipts.Add(receipt);
                }
                await _notifier.Notify(new ReceiptContainer(generatedReceipts));
            }
            catch (Exception e)
            {
                _logHandler.LogError(e.Message);
            }
        }
        public ListResult <ProductDto> GetPackageProductListById_UI(long packageId)
        {
            try
            {
                var post           = new PostServiceProvider();
                var postpriceparam = new PostGetDeliveryPriceParam
                {
                    Price       = 1000000,
                    Weight      = 1000,
                    ServiceType = 2,// (int)customerOrder.PostTypeId,
                    ToCityId    = 39751
                };
                var postresult = post.GetDeliveryPrice(postpriceparam).Result;


                var res = _repository.PackageProduct
                          .FindByCondition(c => c.PackageId == packageId && c.DaDate == null && c.Ddate == null)
                          .Include(c => c.Product).Select(c => c.Product).ToList();
                var result = _mapper.Map <List <ProductDto> >(res);

                var finalresult = ListResult <ProductDto> .GetSuccessfulResult(result);

                return(finalresult);
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod(), packageId);
                return(ListResult <ProductDto> .GetFailResult(e.Message));
            }
        }
 public IActionResult GetCustomerListByFilter(CustomerListParam input)
 {
     try
     {
         var res = _repository.Customer.GetCustomerListByFilter(input);
         _logger.LogData(MethodBase.GetCurrentMethod(), res, null, input);
         return(Ok(res));
     }
     catch (Exception e)
     {
         _logger.LogError(e, MethodBase.GetCurrentMethod(), input);
         return(BadRequest(""));
     }
 }
        public IActionResult GetStaticFormsList()
        {
            try
            {
                var res = _repository.DynamicForms.FindByCondition(c => c.DaDate == null && c.Ddate == null)
                          .Include(c => c.DynamiFormImage)
                          .OrderByDescending(c => c.Id).ToList();
                var result = _mapper.Map <List <DynamiFormDto> >(res);

                _logger.LogData(MethodBase.GetCurrentMethod(), result, null);
                return(Ok(res));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod());
                return(BadRequest(e.Message));
            }
        }
        public IActionResult GetEmployeeList()
        {
            try
            {
                var res = _repository.Employee.FindByCondition(c => c.User.DaDate == null)
                          .Include(c => c.User).ThenInclude(c => c.UserRole).ThenInclude(c => c.RoleNavigation)
                          .Select(c => new
                {
                    c.Id,
                    c.User.FullName,
                    RoleList = string.Join(',', c.User.UserRole.Select(x => x.RoleNavigation.Name).ToList()),
                    Status   = c.User.DaDate == null ? "فعال" : "غیرفعال"
                })
                          .ToList();


                _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
                return(Ok(res));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod());
                return(BadRequest(e.Message));
            }
        }
Example #13
0
        public IActionResult GetComissionList()
        {
            try
            {
                var res = _repository.Comission.FindByCondition(c => c.DaDate == null && c.Ddate == null)
                          .Include(c => c.ProductComission).ThenInclude(c => c.Product)
                          .Select(c => new
                {
                    c.Id,
                    c.Description,
                    c.Title,
                    c.SendEmail,
                    c.SendSms,
                    c.FinalStatusId,
                    c.Value,
                    productList = c.ProductComission.Select(x => string.Join("-", x.Product.Name))
                })
                          .AsNoTracking().ToList();

                _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
                return(Ok(res));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod());
                return(BadRequest(e.Message));
            }
        }
Example #14
0
        public IActionResult GetCustomerFavorites()
        {
            try
            {
                var userId     = ClaimPrincipalFactory.GetUserId(User);
                var customerId = _repository.Customer.FindByCondition(c => c.UserId == userId).Select(c => c.Id)
                                 .FirstOrDefault();

                var res = _repository.CustomerFavoriteProducts.FindByCondition(c => c.CustomerId == customerId)
                          .Include(c => c.Product)
                          .GroupBy(c => new { c.ProductId, c.Product.Name, c.Product.Coding })
                          .Select(c => new { c.Key.Name, c.Key.Coding, c.Key.ProductId, Count = c.Count() }).ToList();



                _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
                return(Ok(res));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod());
                return(BadRequest(e.Message));
            }
        }
 public IActionResult GetImageListByProductId(long productId)
 {
     try
     {
         var res = _repository.ProductImage
                   .FindByCondition(c => c.ProductId == productId && c.Ddate == null && c.DaDate == null).ToList();
         _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
         return(Ok(res));
     }
     catch (Exception e)
     {
         _logger.LogError(e, MethodBase.GetCurrentMethod());
         return(BadRequest(e.Message));
     }
 }
Example #16
0
        public IActionResult GetRoleList()
        {
            try
            {
                var res = _repository.Role.FindByCondition(c => c.Ddate == null && c.DaDate == null)
                          .Include(c => c.CatRole)
                          .Select(c => new { c.Id, c.Name, c.Rkey, CatRole = c.CatRole.Name })
                          .ToList();


                _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
                return(Ok(res));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod());
                return(BadRequest(e.Message));
            }
        }
Example #17
0
 public IActionResult GetBuyCardsList()
 {
     try
     {
         var res = _repository.Product.FindByCondition(c => c.CatProduct.Rkey == 1 && c.Ddate == null)
                   .Select(c => new
         {
             c.Id,
             c.Name,
             c.Count,
             c.Price,
             Status = c.DaDate == null ? "فعال" : "غیرفعال"
         }).ToList();
         _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
         return(Ok(res));
     }
     catch (Exception e)
     {
         _logger.LogError(e, MethodBase.GetCurrentMethod());
         return(BadRequest(e.Message));
     }
 }
 public IActionResult GetOrderStatusList()
 {
     try
     {
         var res = _repository.Status
                   .FindByCondition(c => c.CatStatus.Tables.Any(x => x.Name == "CustomerOrder"))
                   .Select(c => new { c.Id, c.Name }).ToList();
         _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
         return(Ok(res));
     }
     catch (Exception e)
     {
         _logger.LogError(e, MethodBase.GetCurrentMethod());
         return(BadRequest(e.Message));
     }
 }
 public IActionResult GetPackingTypeList(long?languageId)
 {
     try
     {
         var res = _repository.PackingType.FindByCondition(c => c.DaDate == null && c.Ddate == null && (!languageId.HasValue || c.LanguageId == languageId))
                   .Include(c => c.PackingTypeImage)
                   .Include(c => c.ProductPackingType)
                   .Select(c => new
         {
             c.Id,
             c.Name,
             c.Price,
             c.Weight,
             c.Material,
             c.Count,
             c.ColorId,
             Image       = c.PackingTypeImage.Where(c => c.Ddate == null && c.FileType == 2).Select(x => x.ImageFileUrl).FirstOrDefault(),
             ProductName = string.Join(',', c.ProductPackingType.Select(x => x.Product.Name).ToList()),
             Status      = c.DaDate == null ? "فعال" : "غیرفعال"
         }).ToList();
         _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
         return(Ok(res));
     }
     catch (Exception e)
     {
         _logger.LogError(e, MethodBase.GetCurrentMethod());
         return(BadRequest(e.Message));
     }
 }
Example #20
0
        public IActionResult GetCatProductList_Admin()
        {
            try
            {
                var res = _repository.CatProduct.FindByCondition(c => c.DaDate == null && c.Ddate == null)
                          .Select(c => new
                {
                    c.Id,
                    c.Name,
                    c.Coding,
                    c.Icon,
                    c.Pid
                }).ToList();

                _logger.LogData(MethodBase.GetCurrentMethod(), res, null);
                return(Ok(res));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod());
                return(BadRequest(e.Message));
            }
        }
Example #21
0
        public IActionResult InsertProduct()
        {
            var coverpath    = "";
            var downloadpath = "";

            try
            {
                var product       = JsonSerializer.Deserialize <Product>(HttpContext.Request.Form["Product"]);
                var releventList  = JsonSerializer.Deserialize <List <long> >(HttpContext.Request.Form["releventList"]);
                var coverImageUrl = HttpContext.Request.Form.Files.GetFile("CoverImage");
                var downloadLink  = HttpContext.Request.Form.Files.GetFile("DownloadLink");



                if (coverImageUrl != null)
                {
                    var uploadFileStatus = FileManeger.FileUploader(coverImageUrl, 1, "ProductImages");
                    if (uploadFileStatus.Status == 200)
                    {
                        coverpath = uploadFileStatus.Path;
                    }
                    else
                    {
                        return(BadRequest(uploadFileStatus.Path));
                    }
                }
                if (downloadLink != null && product.VirtualProduct.Value)
                {
                    var uploadFileStatus = FileManeger.FileUploader(downloadLink, 3, "ProductFiles");
                    if (uploadFileStatus.Status == 200)
                    {
                        downloadpath = uploadFileStatus.Path;
                    }
                    else
                    {
                        return(BadRequest(uploadFileStatus.Path));
                    }
                }


                product.CoverImageUrl = coverpath;
                product.DownloadLink  = downloadpath;
                product.CuserId       = ClaimPrincipalFactory.GetUserId(User);
                product.Cdate         = DateTime.Now.Ticks;

                var counter = (_repository.Product
                               .FindByCondition(c => c.Coding.ToString().Substring(0, 9) == product.Coding.ToString())
                               .Count() + 1).ToString();
                counter = counter.PadLeft(3, '0');

                product.Coding = Convert.ToInt64(string.Concat(product.Coding.ToString(), counter));

                product.LastSeenDate = DateTime.Now.Ticks;
                product.SeenCount    = 0;


                var parameters = _repository.CatProductParameters
                                 .FindByCondition(c => c.CatProductId == product.CatProductId).ToList();

                parameters.ForEach(c =>
                {
                    var paramss = new ProductCatProductParameters
                    {
                        CatProductParametersId = c.Id,
                        CuserId = ClaimPrincipalFactory.GetUserId(User),
                        Cdate   = DateTime.Now.Ticks
                    };
                    product.ProductCatProductParameters.Add(paramss);
                });
                releventList.ForEach(c =>
                {
                    var pro = new RelatedProduct
                    {
                        CuserId         = ClaimPrincipalFactory.GetUserId(User),
                        Cdate           = DateTime.Now.Ticks,
                        DestinProductId = c
                    };
                    product.RelatedProductOriginProduct.Add(pro);
                });

                _repository.Product.Create(product);


                _repository.Save();

                return(NoContent());
            }
            catch (Exception e)
            {
                FileManeger.FileRemover(new List <string> {
                    coverpath, downloadpath
                });
                _logger.LogError(e, MethodBase.GetCurrentMethod());
                return(BadRequest(e.Message));
            }
        }
Example #22
0
        protected void Application_Error()
        {
            var error = Server.GetLastError();

            _log.LogError(error.Message);
        }