Exemple #1
0
        public string AddNewVariety(ProductMasterViewModel objProductMasterViewModel)
        {
            var existingVarietyId = (from variety in dbContext.Variety_Master where variety.VarietyName == objProductMasterViewModel.NewVariety && variety.CropId == objProductMasterViewModel.CropId select variety.VarietyId).FirstOrDefault();

            var checkVariety = (from variety in dbContext.Variety_Master where variety.VarietyName == objProductMasterViewModel.NewVariety && variety.CropId == objProductMasterViewModel.CropId select variety.VarietyName).FirstOrDefault();

            if (string.IsNullOrEmpty(checkVariety))
            {
                Variety_Master objVariety_Master = new Variety_Master();

                objVariety_Master.VarietyName = objProductMasterViewModel.NewVariety;
                objVariety_Master.CropId      = Convert.ToInt32(objProductMasterViewModel.CropId);

                dbContext.Variety_Master.Add(objVariety_Master);
                var j         = dbContext.SaveChanges();
                int VarietyId = objVariety_Master.VarietyId; // Get OrderId After Save Changes
                if (j != 0)
                {
                    objProductMasterViewModel.VarietyId = VarietyId;
                    objResponse.Message = "Variety Added successfully";
                    return(objResponse.Message);
                }
                else
                {
                    objResponse.Message = "Failed";
                    return(objResponse.Message);
                }
            }
            else
            {
                objProductMasterViewModel.VarietyId = existingVarietyId;
                objResponse.Message = "Variety already exists";
                return(objResponse.Message);
            }
        }
Exemple #2
0
        public ProductMasterViewModel GetAllProduct(int currentPage, string CategoryName)
        {
            try
            {
                int maxRows = 10;
                using (GrowOnlineDevEntities entities = new GrowOnlineDevEntities())
                {
                    ProductMasterViewModel customerModel = new ProductMasterViewModel();

                    customerModel.Customers = (from customer in entities.Shop_Product_Master
                                               where customer.crp_catagory == CategoryName && customer.Status == "Active"
                                               select customer)
                                              .OrderBy(customer => customer.pkSkuId)
                                              .Skip((currentPage - 1) * maxRows)
                                              .Take(maxRows).ToList();

                    double pageCount = (double)((decimal)entities.Shop_Product_Master.Count() / Convert.ToDecimal(maxRows));
                    customerModel.PageCount = (int)Math.Ceiling(pageCount);

                    customerModel.CurrentPageIndex = currentPage;

                    return(customerModel);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
0
        public List <ProductMasterViewModel> GetAllProductList(int take, int skip, string categoryid, string stateid, string searchtext, string CompanyName = "", string sort = "", string CropName = "", int MinPrice = 0, int MaxPrice = 0)
        {
            try
            {
                int totalCount       = 0;
                var DTParameterModel = new DTParameterModel();
                List <ProductMasterViewModel> data = unitOfWork.Shop_Product_MasterRepository.GetAllList(out totalCount, ProductFilter(
                                                                                                             take, skip, categoryid, stateid, searchtext, CompanyName, sort, CropName, MinPrice, MaxPrice)).OrderByDescending(y => y.SkuCreatedDate).Select <Shop_Product_Master, ProductMasterViewModel>((Func <Shop_Product_Master, ProductMasterViewModel>)(x =>
                {
                    //string currentLangugae = Thread.CurrentThread.CurrentCulture.ToString();

                    ProductMasterViewModel productMasterViewModel = new ProductMasterViewModel();
                    productMasterViewModel.pkSkuId         = x.pkSkuId;
                    productMasterViewModel.SkuName         = x.SkuName;
                    productMasterViewModel.Price           = x.Price;
                    productMasterViewModel.IntPrice        = x.IntPrice;
                    productMasterViewModel.packingSize     = x.packingSize;
                    productMasterViewModel.CurrentQuantity = x.CurrentQuantity;
                    productMasterViewModel.SkuCreatedDate  = x.SkuCreatedDate;
                    productMasterViewModel.imageUrl        = x.imageUrl;
                    productMasterViewModel.ProductStatus   = x.CurrentQuantity != null ?  x.CurrentQuantity != "0" ? "Available" : "Out of Stock": "Out of Stock";
                    productMasterViewModel.prd_State       = x.prd_State;
                    productMasterViewModel.Status          = x.Status;
                    productMasterViewModel.isApprove       = x.isApprove;
                    productMasterViewModel.crp_catagory    = x.crp_catagory;
                    productMasterViewModel.crop            = x.crop;
                    productMasterViewModel.Description     = x.Description;
                    productMasterViewModel.ProductPriority = x.ProductPriority.ToString();
                    productMasterViewModel.SkuCreatedDate  = x.SkuCreatedDate;

                    return(productMasterViewModel);
                })).OrderBy(z => z.ProductPriority == "1").OrderBy(x => x.ProductPriority == "2")
                                                     .OrderBy(x => x.ProductPriority == "0").OrderByDescending(x => x.SkuCreatedDate).OrderBy(x => x.ProductStatus).ToList();



                if (sort.Trim() != "N/A")
                {
                    if (sort == "Asc")
                    {
                        return(data.OrderBy(x => x.IntPrice).Skip(skip).Take(take).ToList());
                    }
                    else if (sort == "Desc")
                    {
                        return(data.OrderByDescending(x => x.IntPrice).Skip(skip).Take(take).ToList());
                    }
                    else
                    {
                        return(data.Skip(skip).Take(take).ToList());
                    }
                }
                return(data.Skip(skip).Take(take).ToList());
            }
            catch (Exception ex)

            {
                throw ex;
            }
        }
Exemple #4
0
        public List <ProductMasterViewModel> GetSubCategoryProductList(int take, int skip, string categoryid, string stateid, string searchtext, string sort = "")
        {
            try
            {
                int totalCount       = 0;
                var DTParameterModel = new DTParameterModel();
                List <ProductMasterViewModel> data = unitOfWork.Shop_cropsRepository.GetAllList(out totalCount, GetSubCategoryProductListFilter(
                                                                                                    take, skip, categoryid, stateid, searchtext, sort)).Select <shop_crops, ProductMasterViewModel>((Func <shop_crops, ProductMasterViewModel>)(x =>
                {
                    //string currentLangugae = Thread.CurrentThread.CurrentCulture.ToString();
                    ProductMasterViewModel productMasterViewModel = new ProductMasterViewModel();
                    productMasterViewModel.tr_id                = x.tr_id;
                    productMasterViewModel.crp_Type             = x.crp_Type;
                    productMasterViewModel.crp_catagary         = x.crp_catagary;
                    productMasterViewModel.status               = x.status;
                    productMasterViewModel.imgurl               = x.imgurl;
                    productMasterViewModel.prd_State            = GetStateForSubCategory(x.tr_id);
                    productMasterViewModel.CropRank             = GetCropRank(x.tr_id);
                    productMasterViewModel.CropStatusForDisplay = GetCropStatusFromProduct(stateid, x.crp_Type);

                    return(productMasterViewModel);
                })).ToList();

                // var test = data;

                var filter = data.Where(x => x.CropStatusForDisplay == "In Stock").ToList();
                var result = filter.Skip(skip).Take(take);
                return(result.ToList());
                //if (sort.Trim() != "N/A")
                //{
                //    if (sort == "name")
                //    {

                //        return data.OrderBy(x => x.SkuName).ToList();
                //    }
                //    else if (sort == "price")
                //    {
                //        return data.OrderBy(x => x.Price).ToList();
                //    }
                //    else
                //    {
                //        return data;
                //    }


                //}
            }
            catch (Exception ex)

            {
                throw ex;
            }
        }
Exemple #5
0
        public JsonResult GetProductDetailForCart(string ProductId = "")
        {
            try
            {
                TempData["Product"] = "ProductDetail";
                var getProductDetailbyId = ObjIProductService.GetProductDetail(ProductId);

                ProductMasterViewModel objProductMasterViewModel = new ProductMasterViewModel();


                objProductMasterViewModel.pkSkuId          = getProductDetailbyId.pkSkuId;
                objProductMasterViewModel.SkuName          = getProductDetailbyId.SkuName == null ? "N/A" : getProductDetailbyId.SkuName;
                objProductMasterViewModel.ItemCode         = getProductDetailbyId.ItemCode == null ? "N/A" : getProductDetailbyId.ItemCode;
                objProductMasterViewModel.Description      = getProductDetailbyId.Description == null ? "N /A" : getProductDetailbyId.Description;
                objProductMasterViewModel.Price            = getProductDetailbyId.Price == null ? "N/A" : getProductDetailbyId.Price;
                objProductMasterViewModel.CurrentQuantity  = getProductDetailbyId.CurrentQuantity == null ? "N/A" : getProductDetailbyId.CurrentQuantity;
                objProductMasterViewModel.multipleOf       = getProductDetailbyId.multipleOf == "" ? "10" : getProductDetailbyId.multipleOf;
                objProductMasterViewModel.SkuCreatedDate   = getProductDetailbyId.SkuCreatedDate;
                objProductMasterViewModel.GSTPercent       = getProductDetailbyId.GSTPercent == null ? "N/A" : getProductDetailbyId.GSTPercent;
                objProductMasterViewModel.imageUrl         = getProductDetailbyId.imageUrl == null ? "~/upload/no-image.jpg" : getProductDetailbyId.imageUrl;
                objProductMasterViewModel.min_qty_to_book  = getProductDetailbyId.min_qty_to_book == null ? "N/A" : getProductDetailbyId.min_qty_to_book;
                objProductMasterViewModel.max_qty_to_book  = getProductDetailbyId.max_qty_to_book == null ? "N/A" : getProductDetailbyId.max_qty_to_book;
                objProductMasterViewModel.Prd_company_name = getProductDetailbyId.Prd_company_name == null ? "N/A" : getProductDetailbyId.Prd_company_name;
                objProductMasterViewModel.Allow_SAP_Order  = getProductDetailbyId.Allow_SAP_Order;
                objProductMasterViewModel.prd_State        = getProductDetailbyId.prd_State == null ? "N/A" : getProductDetailbyId.prd_State;
                objProductMasterViewModel.Status           = getProductDetailbyId.Status == null ? "N/A" : getProductDetailbyId.Status;
                objProductMasterViewModel.packingSize      = getProductDetailbyId.packingSize == null ? "N/A" : getProductDetailbyId.packingSize;
                objProductMasterViewModel.crp_priority     = getProductDetailbyId.crp_priority;
                //  objProductMasterViewModel.crp_catagory = getProductDetailbyId.crp_type;
                objProductMasterViewModel.ProductPriority = getProductDetailbyId.ProductPriority.ToString();
                objProductMasterViewModel.crp_catagory    = getProductDetailbyId.crp_catagory == null ? "N/A" : getProductDetailbyId.crp_catagory;
                objProductMasterViewModel.crp_type        = getProductDetailbyId.crp_type == null ? "N/A" : getProductDetailbyId.crp_type;
                objProductMasterViewModel.TC   = getProductDetailbyId.TC == null ? "N/A" : getProductDetailbyId.TC;
                objProductMasterViewModel.crop = getProductDetailbyId.crop == null ? "N/A" : getProductDetailbyId.crop;


                TempData["ReturnAction"] = "product";

                return(Json(objProductMasterViewModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public SavingResult SaveRecord(ProductMasterViewModel ViewModel)
        {
            SavingResult res = new SavingResult();

            if (ViewModel.ProductCode == 0)
            {
                res.ExecutionResult = eExecutionResult.ValidationError;
                res.ValidationError = "Product code is required";
                return(res);
            }

            using (dbUltraCoralEntities db = new dbUltraCoralEntities())
            {
                if (CheckDuplicate(ViewModel.ProductID, ViewModel.ScientificNameID, ViewModel.CommonNameID, ViewModel.Descr, ViewModel.SizeID, ViewModel.CultivationTypeID))
                {
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    res.ValidationError = "Can not accept duplicate values. The product is already exists.";
                    return(res);
                }

                tblProduct SaveModel = null;
                if (ViewModel.ProductID == 0)
                {
                    SaveModel = new tblProduct()
                    {
                        rcdt  = DateTime.Now,
                        rcuid = Common.Props.LoginUser.UserID
                    };
                    db.tblProducts.Add(SaveModel);
                }
                else
                {
                    SaveModel = db.tblProducts.FirstOrDefault(r => r.ProductID == ViewModel.ProductID);
                    if (SaveModel == null)
                    {
                        res.ExecutionResult = eExecutionResult.ValidationError;
                        res.ValidationError = "Selected user has been deleted over network. Can not find user's details. Please retry.";
                        return(res);
                    }

                    SaveModel.redt  = DateTime.Now;
                    SaveModel.reuid = Common.Props.LoginUser.UserID;

                    db.tblProducts.Attach(SaveModel);
                    db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified;
                }

                SaveModel.ProductCode       = ViewModel.ProductCode;
                SaveModel.ScientificNameID  = ViewModel.ScientificNameID;
                SaveModel.CommonNameID      = ViewModel.CommonNameID;
                SaveModel.Descr             = ViewModel.Descr;
                SaveModel.SizeID            = ViewModel.SizeID;
                SaveModel.CultivationTypeID = ViewModel.CultivationTypeID;

                SaveModel.Rate           = ViewModel.Rate;
                SaveModel.RateUpliftPerc = ViewModel.RateUplift;
                SaveModel.UpliftedRate   = ViewModel.Rate + Math.Round((ViewModel.Rate * ViewModel.RateUplift) / 100, 2);

                SaveModel.CurrentStock = ViewModel.CurrentStock;

                //--
                try
                {
                    db.SaveChanges();
                    res.PrimeKeyValue   = SaveModel.ProductID;
                    res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                }
                catch (Exception ex)
                {
                    ex = Common.Functions.FindFinalError(ex);

                    res.ExecutionResult = eExecutionResult.ErrorWhileExecuting;
                    res.Exception       = ex;
                }
            }
            return(res);
        }