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));
            }
        }
Exemplo n.º 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));
     }
 }
Exemplo n.º 3
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));
            }
        }
Exemplo n.º 4
0
 public IActionResult GetProductById(long?sellerId, string productName)
 {
     try
     {
         var result = _repository.Product.FindByCondition(c => c.Ddate == null && c.DaDate == null && (c.SellerId == sellerId || sellerId == null) && (c.Name.Contains(productName) || string.IsNullOrWhiteSpace(productName))).Select(c => new { c.Id, c.Name, }).ToList();
         _logger.LogData(MethodBase.GetCurrentMethod(), result, null, sellerId, productName);
         return(Ok(result));
     }
     catch (Exception e)
     {
         _logger.LogError(e, MethodBase.GetCurrentMethod(), sellerId, productName);
         return(BadRequest(e.Message));
     }
 }
Exemplo n.º 5
0
 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));
     }
 }
        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));
            }
        }
Exemplo n.º 7
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));
            }
        }
Exemplo n.º 8
0
        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));
            }
        }
Exemplo n.º 9
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));
            }
        }
Exemplo n.º 10
0
 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));
     }
 }
Exemplo n.º 11
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));
            }
        }
Exemplo n.º 12
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));
     }
 }
Exemplo n.º 13
0
 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));
     }
 }
Exemplo n.º 14
0
        public IActionResult InsertPackage([FromForm] InsertPackageDto input, [FromForm] FormFileCollection fileList)
        {
            try
            {
                var validator = new ParamValidator();
                validator.ValidateNull(input.Name, General.Messages_.NullInputMessages_.GeneralNullMessage("عنوان"))
                .ValidateNull(input.Price, General.Messages_.NullInputMessages_.GeneralNullMessage("قیمت"))
                .Throw(General.Results_.FieldNullErrorCode());

                if (input.ProductWithPriceList.Count == 0)
                {
                    throw new BusinessException("محصولی برای پکیج انتخاب نشده است.", 4001);
                }


                var counter = (_repository.Product
                               .FindByCondition(c => c.Coding.ToString().Substring(0, 8) == "11223344")
                               .Count() + 1).ToString();
                counter = counter.PadLeft(4, '0');

                var newproduct = new Product
                {
                    Name            = input.Name,
                    Price           = input.Price,
                    MetaDescription = input.MetaDesc,
                    KeyWords        = input.KeyWord,
                    MetaTitle       = input.MetaTitle,
                    Coding          = long.Parse("11223344" + counter),
                    IsPackage       = true,
                    Cdate           = DateTime.Now.Ticks,
                    CuserId         = ClaimPrincipalFactory.GetUserId(User)
                };

                input.ProductWithPriceList.ForEach(c =>
                {
                    var newProductPackage = new ProductPackage()
                    {
                        Cdate        = DateTime.Now.Ticks,
                        CuserId      = ClaimPrincipalFactory.GetUserId(User),
                        DepProductId = c.ProductId,
                        Price        = c.Price
                    };

                    newproduct.ProductPackageDepProduct.Add(newProductPackage);
                });

                fileList.ForEach(c =>
                {
                    short fileType = 1;
                    if (FileManeger.IsVideo(c))
                    {
                        fileType = 2;
                    }
                    var uploadFileStatus = FileManeger.FileUploader(c, fileType, "ProductPackage");
                    if (uploadFileStatus.Status == 200)
                    {
                        var newProductImage = new ProductImage
                        {
                            Cdate    = DateTime.Now.Ticks,
                            CuserId  = ClaimPrincipalFactory.GetUserId(User),
                            ImageUrl = uploadFileStatus.Path,
                            FileType = fileType
                        };
                        newproduct.ProductImage.Add(newProductImage);
                    }
                    else
                    {
                        throw new BusinessException(uploadFileStatus.Path, 4009);
                    }
                });

                _repository.Product.Create(newproduct);
                _repository.Save();
                _logger.LogData(MethodBase.GetCurrentMethod(), newproduct.Id, null, input, "****");
                return(Ok(newproduct.Id));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod(), input, "****");
                return(BadRequest(e.Message));
            }
        }
Exemplo n.º 15
0
 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));
     }
 }
Exemplo n.º 16
0
 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));
     }
 }
Exemplo n.º 17
0
 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(""));
     }
 }
Exemplo n.º 18
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));
            }
        }