コード例 #1
0
        public ActionResult ListDistributors(bool showInactive = false, int page = 1, int itemsperpage = 10, string srchparam = "")
        {
            try
            {
                if (itemsperpage != null)
                {
                    ViewModelBase.ItemsPerPage = itemsperpage;
                }
                bool showinactive = false;
                if (showInactive != null)
                    showinactive = (bool)showInactive;
                ViewBag.showInactive = showinactive;
                if (Session["msg"] != null)
                {
                    ViewBag.msg = Session["msg"].ToString();
                    Session["msg"] = null;
                }
                ViewBag.searchParam = srchparam;
                ViewBag.items = itemsperpage;
              
                var currentPageIndex = page - 1 < 0 ? 0 : page - 1;
                var take = itemsperpage;
                var skip = currentPageIndex * take;
                var query = new QueryStandard { Name = srchparam, ShowInactive = showinactive, Skip = skip, Take = take };
                var ls = _DistributorViewModelBuilder.Query(query);
                var total = ls.Count;
                var data = ls.Data.ToList();
                return View(data.ToPagedList(currentPageIndex, ViewModelBase.ItemsPerPage, total)); 
            }
            catch (Exception ex)
            {
                _log.Debug("Failed to list distributor" + ex.Message);
                _log.Error("Failed to list distributor" + ex.ToString());
                ViewBag.msg = ex.Message;
                HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Test", "Distributor listing error:" + ex.Message);

                return View();

            }

        }
コード例 #2
0
        public ActionResult ListTargets(bool? showInactive, string searchText, int page = 1, int itemsperpage = 10)
        {
            try
            {
                if (itemsperpage != null)
                {
                    ViewModelBase.ItemsPerPage = itemsperpage;
                }
                bool showinactive = false;
                if (showInactive != null)
                    showinactive = (bool)showInactive;
                ViewBag.showInactive = showinactive;
                ViewBag.searchParam = searchText;

                int currentPageIndex = page < 0 ? 0 : page -1;
                int take = itemsperpage;
                int skip = currentPageIndex * take;

                var query = new QueryStandard(){Name = searchText, ShowInactive = showinactive, Skip = skip, Take = take};

                var ls = _targetViewModelBuilder.Query(query);
                var data = ls.Data;
                var count = ls.Count;

                return View(data.ToPagedList(currentPageIndex, ViewModelBase.ItemsPerPage, count));

            }
            catch (Exception ex)
            {
                ViewBag.msg = ex.Message;
            _log.Error("Loading distributor targets"+ex.ToString());
            try
            {
                HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Test", ex.Message);
            }
                catch(Exception exx){}
                return View();
            }
        }
コード例 #3
0
        public ActionResult List(bool? showInactive, int page=1, int itemsperpage=10, string srchParam="")
        {
            try
            {
                if (itemsperpage != null)
                {
                    ViewModelBase.ItemsPerPage = itemsperpage;
                }
                bool showinactive = false;
                if (showInactive != null)
                    showinactive = (bool)showInactive;
                ViewBag.showInactive = showinactive;
                if (TempData["msg"] != null)
                {
                    ViewBag.msg = TempData["msg"].ToString();
                    TempData["msg"] = null;
                
                }

                ViewBag.SearchText = srchParam;

                var currentPageIndex = page-1 < 0 ? 0 : page-1;
                var take = itemsperpage;
                var skip = currentPageIndex*take;

                var query = new QueryStandard
                    {Name = srchParam, ShowInactive = showinactive, Take = take, Skip = skip};
                
                var ls = _commodityViewModelBuilder.Query(query);
                
                var data = ls.Data;
                var total = ls.Count;

                return View(data.ToPagedList(currentPageIndex, ViewModelBase.ItemsPerPage, total));

            }
            catch (Exception ex)
            {

                Log.ErrorFormat("Error in listing Commodity" + ex.Message);
                Log.InfoFormat("Error in listing Commodity" + ex.Message);
                ViewBag.msg = ex.ToString();
                string exception = ex.Message;
                try
                {
                    HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationManager.AppSettings["ServerIP"], ConfigurationManager.AppSettings["UserName"], ConfigurationManager.AppSettings["Password"]);


                    hqm.Send(ConfigurationManager.AppSettings["ServerEmail"], ConfigurationManager.AppSettings["MailGroup"], "Listing Product Pricing", ex.ToString());
                }
                catch (Exception exx) { }
                bool showinactive = false;
                if (showInactive != null)
                    showinactive = (bool)showInactive;
                ViewBag.showInactive = showinactive;
                var ls = _commodityViewModelBuilder.Search("", showinactive);
                //int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
                var currentPageIndex = page < 0 ? 0 : page;
                return View(ls.ToPagedList(currentPageIndex, ViewModelBase.ItemsPerPage));
            }
        }
コード例 #4
0
        public ActionResult List(bool? showInactive, string searchText,int page = 1)
        {
            try
            {
                var user = (CustomIdentity)this.User.Identity;
                Guid? supplerid = user != null ? user.SupplierId : (Guid?)null; 
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();
                int pageSize = 10;
                bool showinactive = false;
                if (showInactive != null)
                    showinactive = (bool)showInactive;
                ViewBag.showInactive = showinactive;
                //if (itemsperpage != null)
                //{
                //    ViewModelBase.ItemsPerPage = itemsperpage;
                //}
                if (TempData["msg"] != null)
                {
                    ViewBag.msg = TempData["msg"].ToString();
                } 
                stopWatch.Stop();
                TimeSpan ts = stopWatch.Elapsed;


                // Format and display the TimeSpan value.
                string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                    ts.Hours,
                    ts.Minutes,
                    ts.Seconds,
                    ts.TotalMilliseconds);


                stopWatch.Reset();
                ViewBag.msg = "";
                _log.InfoFormat("Product Pricing\tTime taken to get all product pricing" + elapsedTime);
                _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "Timestamp", "Product Pricing Controller:" + elapsedTime, DateTime.Now);

                int currentPageIndex = page < 0 ? 0 : page - 1;
                int take = DistributorWebHelper.GetItemPerPage();
                int skip = currentPageIndex*take;


                var query = new QueryStandard()
                {
                    ShowInactive = showinactive,
                    Skip = skip,
                    Take = take,
                    Name = searchText,
                    SupplierId = supplerid
                };
                
                ViewBag.searchParam = searchText;
                var ls = _ppViewModelBuilder.Query(query);
                var data = ls.Data;
                
                var count = ls.Count;


                var settings = _settingsRepository.GetByKey(SettingsKeys.NumberOfDecimalPlaces);
                var decimalPlaces = settings != null ? settings.Value : "4";
                ViewBag.DecimalFormat = string.Format("N{0}", decimalPlaces);

                return View(data.ToPagedList(currentPageIndex, take,count));
                
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Error in listing product pricing" + ex.Message);
                _log.InfoFormat("Error in listing product pricing" + ex.Message);
                ViewBag.msg = ex.ToString();
                string exception = ex.Message;
                try
                {
                    HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                    hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Listing Product Pricing", ex.ToString());
                }
                catch (Exception exx) { }
                    ProductPricingViewModel productPricingVM = new ProductPricingViewModel();
                productPricingVM.ErrorText = exception;
                return View(productPricingVM);
            }
        
        }
コード例 #5
0
        public ActionResult ListPricingItems(Guid id, int? itemsperpage)
        {
            try
            {
                if (itemsperpage != null)
                {
                    ViewModelBase.ItemsPerPage = itemsperpage.Value;
                }
                EditProductPricingViewModel al = _editProductPricingViewModelBuilder.Get(id);
                return View(al);
            }
            catch (Exception ex)
            {
                ViewBag.msg = ex.ToString();
                string exception = ex.Message;
                try
                {
                    HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                    hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Listing Product Pricing", ex.ToString());
                }
                catch { }
                    ProductPricingViewModel productPricingVM = new ProductPricingViewModel();

                productPricingVM.ErrorText = exception;
                return View(productPricingVM);
            }
        }
コード例 #6
0
        public ActionResult LoadCostCentreAndUsers(int CostCentreID)
        {
            bool showinactive = false;
            try
            {
                if (CostCentreID == 1)
                {
                    var qryResult = _distributorViewModelBuilder.GetAll();
                        // _contactModelViewBuilder.GetAll();// _productFlavourViewModelBuilder.GetByBrand(CostCentreID);

                    return Json(new {ok = true, data = qryResult, message = "ok"});
                }
                else if (CostCentreID == 2)
                {
                    var qryResult = _userViewModelBuilder.GetContactUsers(showinactive);
                        //_userViewModelBuilder.GetAll() ;// _contactModelViewBuilder.GetAll();// _productFlavourViewModelBuilder.GetByBrand(CostCentreID);

                    return Json(new {ok = true, data = qryResult, message = "ok"});
                }
                else if (CostCentreID == 3)
                {
                    var qryResult = _outletViewModelBuilder.GetAll();
                        // _contactModelViewBuilder.GetAll();// _productFlavourViewModelBuilder.GetByBrand(CostCentreID);

                    return Json(new {ok = true, data = qryResult, message = "ok"});
                }
                else if (CostCentreID == 4)
                {
                    var qryResult = _commoditySupplierViewModelBuilder.GetAll();
                   
                    return Json(new { ok = true, data = qryResult, message = "ok" });
                }
                else
                {
                    return Json(new {ok = true, data = "", message = "ok"});
                }

            }
            catch (Exception exx)
            {
                _log.ErrorFormat("Error in getting sub brand as per brand " + exx.Message + "Brand Id=" + CostCentreID);
                _log.InfoFormat("Error in getting sub brand as per brand " + exx.Message + "Brand Id=" + CostCentreID);
                try
                {
                    HQMailerViewModelBuilder hqm =
                        new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"],
                                                     ConfigurationSettings.AppSettings["UserName"],
                                                     ConfigurationSettings.AppSettings["Password"]);


                    hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"],
                             ConfigurationSettings.AppSettings["MailGroup"], "Test",
                             "editing sale product error:" + exx.Message);
                }
                catch (Exception ex)
                {
                }
                return Json(new {ok = false, message = exx.Message});
            }
        }
コード例 #7
0
        public ActionResult ImportProduct(HttpPostedFileBase file)
        {

            try
            {

                var fileName = Path.GetFileName(file.FileName);


                var directory = Server.MapPath("~/Uploads");
                if (Directory.Exists(directory) == false)
                {
                    Directory.CreateDirectory(directory);
                }
                var path = Server.MapPath("~/Uploads") + "\\" + fileName;


                file.SaveAs(path);


                string fileExtension = Path.GetExtension(fileName);
                if (fileExtension == ".xlsx")
                {
                    ViewBag.msg = "Please wait. Upload in progress";

                    string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties='Excel 12.0;HDR=YES;'";

                    OleDbConnection conn = new OleDbConnection(connectionString);
                    try
                    {
                        conn.Open();
                        string product = "";
                        OleDbCommand commProduct = new OleDbCommand("SELECT product FROM [Sheet1$]", conn);
                        OleDbDataReader readProduct = commProduct.ExecuteReader();
                        while (readProduct.Read())
                        {
                            product = readProduct["product"].ToString();
                        }
                        if (product == "Sale Product")
                        {
                            OleDbCommand command = new OleDbCommand("SELECT brandCode,subBrandCode,packagingtypeCode,packagingCode,productTypeCode,vatClass,code,description FROM [Sheet1$]", conn);
                            OleDbDataReader reader = command.ExecuteReader();
                            SaleProductViewModel pdvm = new SaleProductViewModel();
                            while (reader.Read())
                            {

                                string brandCode = reader["brandCode"].ToString();
                                string subBrandCode = reader["subBrandCode"].ToString();
                                string packagingTypeCode = reader["packagingTypeCode"].ToString();
                                string packagingCode = reader["packagingCode"].ToString();
                                string productTypeCode = reader["productTypeCode"].ToString();
                                string vatClass = reader["vatClass"].ToString();
                                string productCode = reader["code"].ToString();
                                string description = reader["description"].ToString();

                                pdvm.brandCode = brandCode;
                                pdvm.subBrandCode = subBrandCode;
                                pdvm.packTypeCode = packagingTypeCode;
                                pdvm.packCode = packagingCode;
                                pdvm.productTypeCode = productTypeCode;
                                pdvm.vatClass = vatClass;
                                pdvm.ProductCode = productCode;
                                pdvm.Description = description;
                                _productViewModelBuilder.SaveSaleProduct(pdvm);

                            }
                        }
                        else if (product == "Returnable Product")
                        {
                            OleDbCommand command = new OleDbCommand("SELECT Brand,SubBrand,PackagingType,Packaging,ProductType,VatClass,ProductCode,Description,returnableType FROM [Sheet1$]", conn);
                            OleDbDataReader reader = command.ExecuteReader();
                            EditReturnableProductViewModelIn pdvm = new EditReturnableProductViewModelIn();
                            while (reader.Read())
                            {

                                string brandCode = reader["brand"].ToString();
                                string subBrandCode = reader["subBrand"].ToString();
                                string packagingTypeCode = reader["packagingType"].ToString();
                                string packagingCode = reader["packaging"].ToString();
                                string productTypeCode = reader["productType"].ToString();
                                string vatClass = reader["vatClass"].ToString();
                                string productCode = reader["productcode"].ToString();
                                string description = reader["description"].ToString();
                                string returnableType = reader["returnableType"].ToString();

                                pdvm.brandCode = brandCode;
                                pdvm.subBrandCode = subBrandCode;
                                pdvm.packTypeCode = packagingTypeCode;
                                pdvm.packCode = packagingCode;
                                pdvm.productTypeCode = productTypeCode;
                                pdvm.vatClass = vatClass;
                                pdvm.ProductCode = productCode;
                                pdvm.Description = description;
                                pdvm.RetunableTypeName = returnableType;
                                _productViewModelBuilder.Save(pdvm);

                            }
                        }
                        else if (product == "Consolidated Product")
                        {
                            OleDbCommand command = new OleDbCommand("SELECT brandCode,packagingtypeCode,packagingCode,code,description FROM [Sheet1$]", conn);
                            OleDbDataReader reader = command.ExecuteReader();
                            EditConsolidatedProductOut vm = new EditConsolidatedProductOut();

                            string brandCode = reader["brandCode"].ToString();
                            string packagingTypeCode = reader["packagingTypeCode"].ToString();
                            string packagingCode = reader["packagingCode"].ToString();
                            string code = reader["Code"].ToString();
                            string description = reader["description"].ToString();

                            vm.brandCode = brandCode;
                            vm.packagingTypeCode = packagingTypeCode;
                            vm.packagingCode = packagingCode;
                            vm.ProductCode = code;
                            vm.Description = description;
                            _productViewModelBuilder.Save(vm);
                        }
                    }
                    catch (OleDbException ex)
                    {
                        ViewBag.msg = ex.ToString();
                        try
                        {
                            HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                            hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Test", "editing sale product error:" + ex.Message);
                        }
                        catch (Exception exx)
                        { }
                        return View();
                    }

                    finally
                    {
                        conn.Close();

                    }

                    fi = new FileInfo(path);

                    fi.Delete();
                    _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "Import", "Product", DateTime.Now);
                    ViewBag.msg = "Upload Successful";
                    return RedirectToAction("Index");
                }

                else
                {
                    fi = new FileInfo(path);

                    fi.Delete();
                    ViewBag.msg = "Please upload excel file with extension .xlsx";
                    return View();
                }
            }
            catch (Exception ex)
            {

                ViewBag.msg = ex.ToString();
                try
                {
                    HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                    hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Test", "editing sale product error:" + ex.Message);
                }
                catch (Exception exx)
                { }
                return View();
            }


        }
コード例 #8
0
        public ActionResult SubBrands(Guid brandId)
        {
            try
            {
                var brands = _productFlavourViewModelBuilder.GetByBrand(brandId);
               
                return Json(new { ok = true, data = brands, message = "ok" });
            }
            catch (Exception exx)
            {
                _log.ErrorFormat("Error in getting sub brand as per brand " + exx.Message+"Brand Id="+brandId);
                _log.InfoFormat("Error in getting sub brand as per brand " + exx.Message + "Brand Id=" + brandId);
                try
                {
                    HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                    hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Test", "editing sale product error:" + exx.Message);
                }
                catch (Exception ex)
                { }
                return Json(new { ok=false,message=exx.Message});
            }
        }
コード例 #9
0
        public ActionResult Delete(Guid id) {
            try
            {
                _productViewModelBuilder.SetAsDeleted(id);
                _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "Delete", "Product", DateTime.Now);
                TempData["msg"] = "Successfully Deleted";
            }
            catch (Exception ex)
            {
                TempData["msg"] = ex.Message;
                ViewBag.msg = ex.Message;
                _log.ErrorFormat("Error in deleting product " + ex.Message);
                _log.InfoFormat("Error in deleting product " + ex.Message);
                try
                {
                    HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                    hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Test", "editing sale product error:" + ex.Message);
                }
                catch (Exception exx)
                { }
            }
            return RedirectToAction("Index");
            
        }
コード例 #10
0
        public ActionResult AddItem(EditConsolidatedProductOut spvm, Guid parentId)
        {
            ViewBag.BrandsList = _productViewModelBuilder.GetBrands();

            ViewBag.PackagingsList = _productViewModelBuilder.GetPackaging();
            ViewBag.PackTypeList = _productViewModelBuilder.GetPackagingType();
            try
            {
                spvm.Id = parentId;
                _productViewModelBuilder.AddItemToConsolidatedProduct(spvm);
                _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "Create", "Consolidated Product Item", DateTime.Now);
                return RedirectToAction("AddItem", new { id = spvm.Id });
            }
            catch (Exception ex)
            {
                ViewBag.msg = ex.Message;
                try
                {
                    HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                    hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Test", "editing sale product error:" + ex.Message);
                }
                catch (Exception exx)
                { }
                return RedirectToAction("AddItem", new { id = spvm.Id });
            }
        }
コード例 #11
0
         public ActionResult CreateConsolidatedProduct(EditConsolidatedProductOut spvm, Guid? thisId)
        {
            ViewBag.BrandsList = _productViewModelBuilder.GetBrands();
           
            ViewBag.PackagingsList = _productViewModelBuilder.GetPackaging();
            ViewBag.PackTypeList = _productViewModelBuilder.GetPackagingType();
           
            try
            {
                if (spvm.Description == null)
                {
                    ModelState.AddModelError("Consolidated Product", "Consolidated product is required");
                   //return View();
                   TempData["msg"] = "Product Name Is Required";
                   ViewBag.msg = TempData["msg"].ToString();
                    return RedirectToAction("CreateConsolidatedProduct", new { @thisId = 0 });
                }
                else
                {
                    spvm.Id = thisId.Value;
                    spvm.Id = Guid.NewGuid();
                    _productViewModelBuilder.Save(spvm);
                    _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "Create", "Consolidated Product", DateTime.Now);
                    _log.Info("Saving Consolidated Product:" + spvm);
                    TempData["msg"] = "Consolidated Product Successfully Created";
                    return RedirectToAction("Index");
                }
                
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Error in creating consolidated product " + ex.Message);
                _log.InfoFormat("Error in creating consolidated product " + ex.Message);
                try
                {
                    HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                    hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Test", "editing sale product error:" + ex.Message);
                }
                catch (Exception exx)
                { }
                return View();
            }
        }
コード例 #12
0
         public ActionResult EditConsolidatedProduct(EditConsolidatedProductOut vm, Guid? thisId)
        {
            
            ViewBag.BrandsList = _productViewModelBuilder.GetBrands();
            ViewBag.FlavoursList = _productViewModelBuilder.GetFlavours();
            ViewBag.PackagingsList = _productViewModelBuilder.GetPackaging();
            ViewBag.PackTypeList = _productViewModelBuilder.GetPackagingType();
            ViewBag.ProductTypeList = _productViewModelBuilder.GetProductType();
            //vm.Id = thisId.Value;
            try
            {
                //vm.Id = thisId;
                _productViewModelBuilder.Save(vm);
                _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "Edit", "Consolidated Product", DateTime.Now);
                TempData["msg"] = "Consolidated Product Successfully Edited";
                return RedirectToAction("Index");
            }
            catch (DomainValidationException dve)
            {
                ValidationSummary.DomainValidationErrors(dve, ModelState);
                _log.ErrorFormat("Error in consolidated product " + dve.Message);
                _log.InfoFormat("Error in consolidated product " + dve.Message);
                ViewBag.msg = dve.Message;
                return View();
            }
            catch (Exception ex)
            {
                ViewBag.msg = ex.Message;
                _log.ErrorFormat("Error in consolidated product pricing" + ex.Message);
                _log.InfoFormat("Error in consolidated product pricing" + ex.Message);
                try
                {
                    HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                    hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Test", "editing sale product error:" + ex.Message);
                }
                catch (Exception exx)
                { }
                return View();
            }
        }
コード例 #13
0
        public ActionResult CreateReturnableProduct(ReturnableProductViewModel vm)
        {
           
            try
            {
                ViewBag.msg = null;
                vm.Id = Guid.NewGuid();
                _productViewModelBuilder.CreateReturnableProduct(vm);
                _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "Edit", "Returnable Product", DateTime.Now);
                TempData["msg"] = "Returnable Product Successfully Created";

                return RedirectToAction("Index");
            }
            catch (DomainValidationException dve)
            {
                ValidationSummary.DomainValidationErrors(dve, ModelState);
                ViewBag.BrandsList = _productViewModelBuilder.GetBrands();
                ViewBag.PackagingsList = _productViewModelBuilder.GetPackaging();
                ViewBag.PackTypeList = _productViewModelBuilder.GetPackagingType();
                ViewBag.ReturnableTypeList = _productViewModelBuilder.GetReturnableType();
                ViewBag.FlavoursList = _productViewModelBuilder.GetFlavours();
                ViewBag.VatClassList = _productViewModelBuilder.VatClass();
                ViewBag.RetReturnableProductList = _productViewModelBuilder.GetRetReturnableProducts();
                _log.ErrorFormat("Error in editing returnable product " + dve.Message);
                _log.InfoFormat("Error in editing returnable product " + dve.Message);
                ViewBag.Title = "Edit Returnable Product";
                
                return View();
            }
            catch (Exception ex)
            {
                ViewBag.msg = ex.Message;
                ViewBag.msg = ex.ToString();
                ViewBag.BrandsList = _productViewModelBuilder.GetBrands();
                ViewBag.PackagingsList = _productViewModelBuilder.GetPackaging();
                ViewBag.PackTypeList = _productViewModelBuilder.GetPackagingType();
                ViewBag.ReturnableTypeList = _productViewModelBuilder.GetReturnableType();
                ViewBag.FlavoursList = _productViewModelBuilder.GetFlavours();
                ViewBag.VatClassList = _productViewModelBuilder.VatClass();
                ViewBag.RetReturnableProductList = _productViewModelBuilder.GetRetReturnableProducts();
                ViewBag.Title = "Edit Returnable Product";
                try
                {
                    HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                    hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Test", "editing sale product error:" + ex.Message);
                }
                catch (Exception exx)
                { }
                return View(vm);
            }
            
        }
コード例 #14
0
        public ActionResult DistributorRoutes(Guid distributorId)
        {
            try
            {
                var regionId = _outletViewModelBuilder.GetRegionIdForDistributor(distributorId);

               var routes =_adminRouteViewModelBuilder.GetByDistributor(regionId);
               
                if (routes.Count != 0)
                {
                    return Json(new { ok = true, data = routes, message = "ok" });
                }
                else
                {
                    var defaultRoute = _adminRouteViewModelBuilder.GetAll().Where(n => n.Name == "[Shop]").ToList();

                    return Json(new { ok = true, data = defaultRoute, message = "ok" });
                }

            }
            catch (Exception exx)
            {
                _log.ErrorFormat("Error in getting routes as per distributor " + exx.Message + "Distributor Id=" + distributorId);
                _log.InfoFormat("Error in getting routes as per distributor " + exx.Message + "Distributor Id=" + distributorId);
                try
                {
                    HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                    hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Test", "editing sale product error:" + exx.Message);
                }
                catch (Exception ex)
                { }
                return Json(new { ok = false, message = exx.Message });
            }
        }
コード例 #15
0
        public ActionResult EditDistributor(DistributorViewModel dvm)
        {
            //ViewBag.RegionList = _DistributorViewModelBuilder.Region();
            //ViewBag.ASMList = _DistributorViewModelBuilder.ASM();
            //ViewBag.SalesRepList = _DistributorViewModelBuilder.SalesRep();
            //ViewBag.SurveyorList = _DistributorViewModelBuilder.Surveyor();
            try
            {
                _DistributorViewModelBuilder.Save(dvm);
                _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "Edit", "Distributor", DateTime.Now);
                Session["msg"] = "Distributor Successfully Edited";
                return RedirectToAction("listDistributors");
            }
            catch (DomainValidationException dve)
            {
                ValidationSummary.DomainValidationErrors(dve,ModelState);
                _log.Debug("Failed to edit distributor" + dve.Message);
                _log.Error("Failed to edit distributor" + dve.ToString());
                return View();
            }
            catch (Exception ex)
            {
                _log.Debug("Failed to edit distributor" + ex.Message);
                _log.Error("Failed to edit distributor" + ex.ToString());
                HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Test", "Edit Distributor error:" + ex.Message);

                return View();
            }

        }
コード例 #16
0
        public ActionResult CreateDistributor(DistributorViewModel dvm)
        {
            ViewBag.RegionList = _DistributorViewModelBuilder.Region();
            ViewBag.ASMList = _DistributorViewModelBuilder.ASM();
            ViewBag.SalesRepList = _DistributorViewModelBuilder.SalesRep();
            ViewBag.SurveyorList = _DistributorViewModelBuilder.Surveyor();
            //ViewBag.TierList = _DistributorViewModelBuilder.PricingTier();
            try
            {
                if (dvm.RegionId == Guid.Empty)
                {
                    ModelState.AddModelError("Distributor", "Region is required");
                    return View();
                }
                else
                {
                    dvm.Id = Guid.NewGuid();
                    _DistributorViewModelBuilder.Save(dvm);
                    _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "Create", "Distributor", DateTime.Now);
                    Session["msg"] = "Distributor Successfully Created";
                    var latestDistributr = _DistributorViewModelBuilder.Get(dvm.Id);//.Where(n => n.DateCreated < DateTime.Now).OrderByDescending(n => n.DateCreated).ThenByDescending(n => n.id).ToList()[0];//;
                    //  DistributorViewModel  latestDistributr = _DistributorViewModelBuilder.GetAll().FirstOrDefault(n=>n.DateCreated<DateTime.Now);

                    Guid distributrId = latestDistributr.Id;
                    string distributorName = latestDistributr.Name;
                    // return RedirectToAction("listDistributors");
                    return RedirectToAction("CreateContact", "Contact", new { CostCentre = distributrId, CostCentreName = distributorName, ContactFor = "Distributor" });
                }
            }
            catch (DomainValidationException dve)
            {

                ValidationSummary.DomainValidationErrors(dve, ModelState);
                _log.Debug("Failed to create distributor" + dve.Message);
                _log.Error("Failed to create distributor" + dve.ToString());
                return View();
            }
            catch (Exception ex)
            {
                ViewBag.msg = ex.Message;
                _log.Debug("Failed to create distributor" + ex.Message);
                _log.Error("Failed to create distributor" + ex.ToString()); HQMailerViewModelBuilder hqm = new HQMailerViewModelBuilder(ConfigurationSettings.AppSettings["ServerIP"], ConfigurationSettings.AppSettings["UserName"], ConfigurationSettings.AppSettings["Password"]);


                hqm.Send(ConfigurationSettings.AppSettings["ServerEmail"], ConfigurationSettings.AppSettings["MailGroup"], "Test", "Create Distributor error:" + ex.Message);

                return View();
            }

        }