예제 #1
0
        public ActionResult Edit(int Id)
        {
            try
            {
                customerBookingViewModel.Id = Id;
                var customerResult = webServices.Post(customerBookingViewModel, "CustomerBooking/CustomerBookingGetById");

                if (customerResult.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    customerBookingViewModel = (new JavaScriptSerializer().Deserialize <CustomerBookingViewModel>(customerResult.Data.ToString()));
                }

                ProductController     productController     = new ProductController();
                ProductUnitController productUnitController = new ProductUnitController();

                ViewBag.Products     = productController.Products();
                ViewBag.ProductUnits = productUnitController.ProductUnits();

                return(View(customerBookingViewModel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public ActionResult CustomerCreate()
        {
            ProductController     productController     = new ProductController();
            ProductUnitController productUnitController = new ProductUnitController();

            ViewBag.Products     = productController.Products();
            ViewBag.ProductUnits = productUnitController.ProductUnits();

            CustomerBookingViewModel CustomerBookingViewModel = new CustomerBookingViewModel
            {
                VAT         = (decimal)0.00,
                TotalAmount = (decimal)0.00
            };

            return(View(CustomerBookingViewModel));
        }
예제 #3
0
        public ActionResult AdminCreate()
        {
            CompanyController     companyController     = new CompanyController();
            ProductController     productController     = new ProductController();
            ProductUnitController productUnitController = new ProductUnitController();

            ViewBag.Companies    = companyController.Companies();
            ViewBag.Products     = productController.Products();
            ViewBag.ProductUnits = productUnitController.ProductUnits();

            CustomerBookingViewModel CustomerBookingViewModel = new CustomerBookingViewModel
            {
                VAT         = (decimal)0.00,
                TotalAmount = (decimal)0.00,
            };

            return(View(CustomerBookingViewModel));
        }
예제 #4
0
        public ActionResult Update(CustomerBookingViewModel customerBookingViewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    ProductController     productController     = new ProductController();
                    ProductUnitController productUnitController = new ProductUnitController();

                    ViewBag.Products     = productController.Products();
                    ViewBag.ProductUnits = productUnitController.ProductUnits();

                    return(View("Edit", customerBookingViewModel));
                }
                else
                {
                    var CustomerResult = new ServiceResponseModel();
                    if (customerBookingViewModel.Id > 0)
                    {
                        CustomerBookingViewModel customerBookingViewModel1 = new CustomerBookingViewModel
                        {
                            Id           = customerBookingViewModel.Id,
                            BookQuantity = customerBookingViewModel.BookQuantity,
                            UnitPrice    = customerBookingViewModel.UnitPrice,
                            VAT          = customerBookingViewModel.VAT,
                            TotalAmount  = customerBookingViewModel.TotalAmount,
                            Description  = customerBookingViewModel.Description,
                            UpdateBy     = Convert.ToInt32(Session["UserId"]),
                            ProductId    = customerBookingViewModel.ProductId,
                            UnitId       = customerBookingViewModel.UnitId,
                        };
                        UpdateReasonDescriptionViewModel updateReasonDescriptionViewModel1 = new UpdateReasonDescriptionViewModel
                        {
                            Id   = customerBookingViewModel.Id,
                            Flag = "Booking",
                            ReasonDescription = customerBookingViewModel.ReasonDescription,
                            CreatedBy         = customerBookingViewModel1.UpdateBy,
                        };

                        customerBookingViewModel1.UpdateReasonDescriptionViewModel = updateReasonDescriptionViewModel1;

                        CustomerResult = webServices.Post(customerBookingViewModel1, "CustomerBooking/CustomerBookingUpdate");

                        if (CustomerResult.StatusCode == System.Net.HttpStatusCode.Accepted)
                        {
                            var reuslt = (new JavaScriptSerializer().Deserialize <int>(CustomerResult.Data));

                            return(RedirectToAction(nameof(Customer)));
                        }

                        return(View(customerBookingViewModel));
                    }
                    else
                    {
                        return(View(customerBookingViewModel));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #5
0
        public ActionResult CustomerCreate(CustomerBookingViewModel customerBookingViewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    ProductController     productController     = new ProductController();
                    ProductUnitController productUnitController = new ProductUnitController();

                    ViewBag.Products     = productController.Products();
                    ViewBag.ProductUnits = productUnitController.ProductUnits();

                    if (customerBookingViewModel.IsAwfuelAdmin == "IsAwfuelAdmin")
                    {
                        if (customerBookingViewModel.CompanyId == 0)
                        {
                            ModelState.AddModelError("CompanyId", "Please select customer");
                        }
                        CompanyController companyController = new CompanyController();
                        ViewBag.Companies = companyController.Companies();
                        return(View("AdminCreate", customerBookingViewModel));
                    }
                    else
                    {
                        return(View("CustomerCreate", customerBookingViewModel));
                    }
                }
                else
                {
                    if (customerBookingViewModel.IsAwfuelAdmin == "IsAwfuelAdmin")
                    {
                        if (customerBookingViewModel.CompanyId == 0)
                        {
                            CompanyController     companyController     = new CompanyController();
                            ProductController     productController     = new ProductController();
                            ProductUnitController productUnitController = new ProductUnitController();

                            ViewBag.Companies    = companyController.Companies();
                            ViewBag.Products     = productController.Products();
                            ViewBag.ProductUnits = productUnitController.ProductUnits();

                            ModelState.AddModelError("CompanyId", "Please select customer");

                            return(View("AdminCreate", customerBookingViewModel));
                        }
                    }
                    var CustomerResult = new ServiceResponseModel();
                    customerBookingViewModel.CreatedBy = Convert.ToInt32(Session["UserId"]);
                    if (customerBookingViewModel.IsAwfuelAdmin != "IsAwfuelAdmin")
                    {
                        customerBookingViewModel.CompanyId = Convert.ToInt32(Session["CompanyId"]);
                    }
                    CustomerResult = webServices.Post(customerBookingViewModel, "CustomerBooking/CustomerBookingAdd");

                    if (CustomerResult.StatusCode == System.Net.HttpStatusCode.Accepted)
                    {
                        var reuslt = (new JavaScriptSerializer().Deserialize <int>(CustomerResult.Data));

                        if (customerBookingViewModel.IsAwfuelAdmin == "IsAwfuelAdmin")
                        {
                            return(RedirectToAction(nameof(Index)));
                        }
                        else
                        {
                            return(RedirectToAction(nameof(Customer)));
                        }
                    }

                    return(View(customerBookingViewModel));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }