public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(RecordNotFound());
            }
            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(OperationErrorBackToIndex(getOperation.Exception));
            }
            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getCOperation = await _cbo.ReadAsync(getOperation.Result.CategoryId);

            if (!getCOperation.Success)
            {
                return(OperationErrorBackToIndex(getCOperation.Exception));
            }
            if (getCOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getBOperation = await _bbo.ReadAsync(getOperation.Result.BrandId);

            if (!getBOperation.Success)
            {
                return(OperationErrorBackToIndex(getBOperation.Exception));
            }
            if (getBOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var vm = ProductModelViewModel.Parse(getOperation.Result);

            Draw("Details", "fa-search");

            ViewData["Brand"]    = BrandViewModel.Parse(getBOperation.Result);
            ViewData["Category"] = CategoryViewModel.Parse(getCOperation.Result);
            return(View(vm));
        }
Beispiel #2
0
        public string InsertUpdateProductModel(ProductModelViewModel productModelVM)
        {
            object result = null;

            try
            {
                AppUA appUA = Session["AppUA"] as AppUA;
                productModelVM.PSASysCommon             = new PSASysCommonViewModel();
                productModelVM.PSASysCommon.CreatedBy   = appUA.UserName;
                productModelVM.PSASysCommon.CreatedDate = _pSASysCommon.GetCurrentDateTime();
                productModelVM.PSASysCommon.UpdatedBy   = appUA.UserName;
                productModelVM.PSASysCommon.UpdatedDate = _pSASysCommon.GetCurrentDateTime();
                result = _productModelBusiness.InsertUpdateProductModel(Mapper.Map <ProductModelViewModel, ProductModel>(productModelVM));
                return(JsonConvert.SerializeObject(new { Status = "OK", Record = result, Message = "Success" }));
            }
            catch (Exception ex)
            {
                AppConstMessage cm = _appConstant.GetMessage(ex.Message);
                return(JsonConvert.SerializeObject(new { Status = "ERROR", Record = "", Message = cm.Message }));
            }
        }
Beispiel #3
0
        public ActionResult ProductModelSelectList(string required, bool?disabled, Guid productID)
        {
            ViewBag.IsRequired       = required;
            ViewBag.IsDisabled       = disabled;
            ViewBag.HasAddPermission = false;
            ViewBag.propertydisable  = disabled == null ? false : disabled;
            AppUA      appUA      = Session["AppUA"] as AppUA;
            Permission permission = _pSASysCommon.GetSecurityCode(appUA.UserName, "ProductModel");

            if (permission.SubPermissionList.Count > 0)
            {
                if (permission.SubPermissionList.First(s => s.Name == "SelectListAddButton").AccessCode.Contains("R"))
                {
                    ViewBag.HasAddPermission = true;
                }
            }
            ProductModelViewModel productModelVM = new ProductModelViewModel();

            productModelVM.ProductModelSelectList = _productModelBusiness.GetProductModelForSelectList(productID);
            return(PartialView("_ProductModelSelectList", productModelVM));
        }
        public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(OperationErrorBackToIndex(getOperation.Exception));
            }
            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getEOperation = await _ebo.ReadAsync(getOperation.Result.EstablishmentId);

            if (!getEOperation.Success)
            {
                return(OperationErrorBackToIndex(getEOperation.Exception));
            }
            if (getEOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getSBOperation = await _sbbo.ReadAsync(getOperation.Result.ShoppingBasketId);

            if (!getSBOperation.Success)
            {
                return(OperationErrorBackToIndex(getSBOperation.Exception));
            }
            if (getSBOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getPMOperation = await _pmbo.ReadAsync(getOperation.Result.ProductModelId);

            if (!getPMOperation.Success)
            {
                return(OperationErrorBackToIndex(getPMOperation.Exception));
            }
            if (getPMOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getPOperation = await _pbo.ReadAsync(getSBOperation.Result.ProfileId);

            if (!getPOperation.Success)
            {
                return(OperationErrorBackToIndex(getPOperation.Exception));
            }
            if (getPOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getCOperation = await _cbo.ReadAsync(getEOperation.Result.CompanyId);

            if (!getCOperation.Success)
            {
                return(OperationErrorBackToIndex(getCOperation.Exception));
            }
            if (getCOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var vm = ProductUnitViewModel.Parse(getOperation.Result);

            ViewData["Profile"]        = ProfileViewModel.Parse(getPOperation.Result);
            ViewData["Company"]        = CompanyViewModel.Parse(getCOperation.Result);
            ViewData["Establishment"]  = EstablishmentViewModel.Parse(getEOperation.Result);
            ViewData["ShoppingBasket"] = ShoppingBasketViewModel.Parse(getSBOperation.Result);
            ViewData["ProductModel"]   = ProductModelViewModel.Parse(getPMOperation.Result);

            Draw("Details", "fa-search");

            return(View(vm));
        }
        private async Task <ProductModelViewModel> GetProductModelViewModel(Guid id)
        {
            var getOperation = await _pmbo.ReadAsync(id);

            return(ProductModelViewModel.Parse(getOperation.Result));
        }
Beispiel #6
0
        public ActionResult Update([FromBody] ProductModelViewModel productModel)
        {
            var currentRes = _bo.Read(productModel.Id);

            if (!currentRes.Success)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            var current = currentRes.Result;

            if (current == null)
            {
                return(NotFound());
            }

            if (current.Name == productModel.Name && current.BarCode == productModel.BarCode && current.Description == productModel.Description && current.Price.ToString() == productModel.Price && current.Amount.ToString() == productModel.Amount && current.Measure == productModel.Measure && current.BrandId == productModel.BrandId && current.CategoryId == productModel.CategoryId)
            {
                return(StatusCode((int)HttpStatusCode.NotModified));
            }

            if (current.Name != productModel.Name)
            {
                current.Name = productModel.Name;
            }
            if (current.BarCode != productModel.BarCode)
            {
                current.BarCode = productModel.BarCode;
            }
            if (current.Description != productModel.Description)
            {
                current.Description = productModel.Description;
            }
            if (current.Price.ToString() != productModel.Price)
            {
                current.Price = double.Parse(productModel.Price);
            }
            if (current.Amount.ToString() != productModel.Amount)
            {
                current.Amount = double.Parse(productModel.Amount);
            }
            if (current.Measure != productModel.Measure)
            {
                current.Measure = productModel.Measure;
            }
            if (current.BrandId != productModel.BrandId)
            {
                current.BrandId = productModel.BrandId;
            }
            if (current.CategoryId != productModel.CategoryId)
            {
                current.CategoryId = productModel.CategoryId;
            }


            var updateResult = _bo.Update(current);

            if (!updateResult.Success)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            return(Ok());
        }
Beispiel #7
0
        public ExistingComplaintReportViewModel(ComplaintReport c)
        {
            ComplaintReportId = c.ComplaintReportId;
            MachineNo1        = c.MachineNo1;
            MachineNo2        = c.MachineNo2;
            DealerId          = c.MemberId;
            SaleDate          = c.SaleDate;
            DamageDate        = c.DamageDate;
            RepairDate        = c.RepairDate;
            TimeAmount        = c.TimeAmount;
            EngineNo          = c.EngineNo;
            Customer          = new CustomerViewModel()
            {
                CustomerId   = c.Customer.CustomerId,
                Name         = c.Customer.Name,
                Address      = c.Customer.Address,
                CustomerType = c.Customer.CustomerType
            };

            var memberShipHelper = new Umbraco.Web.Security.MembershipHelper(Umbraco.Web.UmbracoContext.Current);
            var memberId         = memberShipHelper.GetCurrentMemberId();
            var memberService    = ApplicationContext.Current.Services.MemberService;
            var m = memberService.GetById(c.MemberId);

            Dealer = new DealerViewModel(m);

            Product      = new ProductViewModel(c.ProductModel.Product);
            ProductModel = new ProductModelViewModel(c.ProductModel);
            Status       = c.Status;

            SelectedProduct      = c.ProductModel.ProductId;
            SelectedProductModel = c.ProductModelId;

            Closed         = c.Closed;
            Error          = c.Error;
            ReasonForError = c.ReasonForError;
            PartsMarked    = c.PartsMarked;
            PartsReturned  = c.PartsReturned;
            CreateEmail    = c.CreateEmail;

            //Parts = new List<PartViewModel>();


            //Parts.AddRange(c.ComplaintReportParts.Select(p =>
            //    new PartViewModel(){
            //        PartId = p.PartId,
            //        Description = p.Description,
            //        PartNo = p.PartNo,
            //        Price = p.Price,
            //        Shipping = p.Shipping,
            //    }));

            var parts = c.ComplaintReportParts.Select(p =>
                                                      new PartViewModel()
            {
                PartId      = p.PartId,
                Description = p.Part.Description,
                PartNo      = p.Part.PartNo,
                Price       = p.Part.Price,
                Shipping    = p.Part.Shipping,
                Amount      = p.Amount
            });

            Parts = new List <PartViewModel>();
            Parts.AddRange(parts);
            SentToApproval = c.SentToApproval;
        }
 public ProductModelView(ProductModelViewModel model)
 {
     InitializeComponent();
     DataContext = model;
 }
        public async Task <IActionResult> Edit(Guid id, ProductModelViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var getOperation = await _bo.ReadAsync(id);

                if (!getOperation.Success)
                {
                    return(OperationErrorBackToIndex(getOperation.Exception));
                }
                if (getOperation.Result == null)
                {
                    return(RecordNotFound());
                }
                var result = getOperation.Result;
                if (!vm.CompareToModel(result))
                {
                    result = vm.ToModel(result);
                    var updateOperation = await _bo.UpdateAsync(result);

                    if (!updateOperation.Success)
                    {
                        TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Exception);

                        getOperation = await _bo.ReadAsync((Guid)id);

                        if (!getOperation.Success)
                        {
                            return(OperationErrorBackToIndex(getOperation.Exception));
                        }
                        if (getOperation.Result == null)
                        {
                            return(RecordNotFound());
                        }

                        vm = ProductModelViewModel.Parse(getOperation.Result);

                        var listBOperation = await _bbo.ListNotDeletedAsync();

                        if (!listBOperation.Success)
                        {
                            return(OperationErrorBackToIndex(listBOperation.Exception));
                        }
                        var listCOperation = await _cbo.ListNotDeletedAsync();

                        if (!listCOperation.Success)
                        {
                            return(OperationErrorBackToIndex(listCOperation.Exception));
                        }

                        ViewBag.Measure = Enum.GetNames(typeof(Measure)).Select(r => new SelectListItem {
                            Text = r, Value = r
                        });;
                        var bList = new List <SelectListItem>();
                        foreach (var item in listBOperation.Result)
                        {
                            var listItem = new SelectListItem()
                            {
                                Value = item.Id.ToString(), Text = item.Name
                            };
                            if (item.Id == vm.BrandId)
                            {
                                listItem.Selected = true;
                            }
                            bList.Add(listItem);
                        }
                        ViewBag.Brands = bList;

                        var cList = new List <SelectListItem>();
                        foreach (var item in listCOperation.Result)
                        {
                            var listItem = new SelectListItem()
                            {
                                Value = item.Id.ToString(), Text = item.Name
                            };
                            if (item.Id == vm.BrandId)
                            {
                                listItem.Selected = true;
                            }
                            cList.Add(listItem);
                        }
                        ViewBag.Categories = cList;

                        Draw("Edit", "fa-edit");

                        return(View(vm));
                    }
                    if (!updateOperation.Result)
                    {
                        TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Message);

                        getOperation = await _bo.ReadAsync((Guid)id);

                        if (!getOperation.Success)
                        {
                            return(OperationErrorBackToIndex(getOperation.Exception));
                        }
                        if (getOperation.Result == null)
                        {
                            return(RecordNotFound());
                        }

                        vm = ProductModelViewModel.Parse(getOperation.Result);

                        var listBOperation = await _bbo.ListNotDeletedAsync();

                        if (!listBOperation.Success)
                        {
                            return(OperationErrorBackToIndex(listBOperation.Exception));
                        }
                        var listCOperation = await _cbo.ListNotDeletedAsync();

                        if (!listCOperation.Success)
                        {
                            return(OperationErrorBackToIndex(listCOperation.Exception));
                        }

                        ViewBag.Measure = Enum.GetNames(typeof(Measure)).Select(r => new SelectListItem {
                            Text = r, Value = r
                        });;

                        var bList = new List <SelectListItem>();
                        foreach (var item in listBOperation.Result)
                        {
                            var listItem = new SelectListItem()
                            {
                                Value = item.Id.ToString(), Text = item.Name
                            };
                            if (item.Id == vm.BrandId)
                            {
                                listItem.Selected = true;
                            }
                            bList.Add(listItem);
                        }
                        ViewBag.Brands = bList;

                        var cList = new List <SelectListItem>();
                        foreach (var item in listCOperation.Result)
                        {
                            var listItem = new SelectListItem()
                            {
                                Value = item.Id.ToString(), Text = item.Name
                            };
                            if (item.Id == vm.BrandId)
                            {
                                listItem.Selected = true;
                            }
                            cList.Add(listItem);
                        }
                        ViewBag.Categories = cList;

                        Draw("Edit", "fa-edit");

                        return(View(vm));
                    }
                    else
                    {
                        return(OperationSuccess("The record was successfuly updated"));
                    }
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Edit(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(OperationErrorBackToIndex(getOperation.Exception));
            }
            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var vm = ProductModelViewModel.Parse(getOperation.Result);

            var listBOperation = await _bbo.ListNotDeletedAsync();

            if (!listBOperation.Success)
            {
                return(OperationErrorBackToIndex(listBOperation.Exception));
            }
            var listCOperation = await _cbo.ListNotDeletedAsync();

            if (!listCOperation.Success)
            {
                return(OperationErrorBackToIndex(listCOperation.Exception));
            }

            ViewBag.Measure = Enum.GetNames(typeof(Measure)).Select(r => new SelectListItem {
                Text = r, Value = r
            });;
            var bList = new List <SelectListItem>();

            foreach (var item in listBOperation.Result)
            {
                var listItem = new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = item.Name
                };
                if (item.Id == vm.BrandId)
                {
                    listItem.Selected = true;
                }
                bList.Add(listItem);
            }
            ViewBag.Brands = bList;

            var cList = new List <SelectListItem>();

            foreach (var item in listCOperation.Result)
            {
                var listItem = new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = item.Name
                };
                if (item.Id == vm.BrandId)
                {
                    listItem.Selected = true;
                }
                cList.Add(listItem);
            }
            ViewBag.Categories = cList;

            Draw("Edit", "fa-edit");

            return(View(vm));
        }
        public async Task <IActionResult> Create(ProductModelViewModel vm)
        {
            var listBOperation = await _bbo.ListNotDeletedAsync();

            if (!listBOperation.Success)
            {
                return(OperationErrorBackToIndex(listBOperation.Exception));
            }

            var listCOperation = await _cbo.ListNotDeletedAsync();

            if (!listCOperation.Success)
            {
                return(OperationErrorBackToIndex(listCOperation.Exception));
            }


            var bList = new List <SelectListItem>();

            foreach (var item in listBOperation.Result)
            {
                bList.Add(new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = item.Name
                });
            }

            var cList = new List <SelectListItem>();

            foreach (var item in listCOperation.Result)
            {
                cList.Add(new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = item.Name
                });
            }
            ViewData["Measure"] = Enum.GetNames(typeof(Measure)).Select(r => new SelectListItem {
                Text = r, Value = r
            });;

            ViewBag.Brands     = bList;
            ViewBag.Categories = cList;

            Draw("Create", "fa-plus");

            if (ModelState.IsValid)
            {
                var model           = vm.ToModel();
                var createOperation = await _bo.CreateAsync(model);

                if (!createOperation.Success)
                {
                    return(OperationErrorBackToIndex(createOperation.Exception));
                }
                if (!createOperation.Result)
                {
                    TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, createOperation.Message);

                    return(View(vm));
                }
                else
                {
                    return(OperationSuccess("The record was successfuly created"));
                }
            }
            return(View(vm));
        }