コード例 #1
0
        public PurchaseDetailsViewModel GetDetails(int?id)
        {
            Purchase purchase = this.Context.Purchases.Find(id);

            if (purchase == null)
            {
                return(null);
            }

            var countBooks = purchase.Books
                             .GroupBy(b => b.Book.Id)
                             .Select(b => new CountBookInBasketViewModel()
            {
                Count    = b.Count(),
                Book     = Mapper.Map <Book, BookDetailsViewModel>(b.First().Book),
                BookId   = b.First().Book.Id,
                NewCount = 0
            }).ToList();

            PurchaseDetailsViewModel viewModel = Mapper.Map <Purchase, PurchaseDetailsViewModel>(purchase);

            foreach (var countBook in countBooks)
            {
                this.CheckForCurrentPromotion(countBook, purchase.CompletedOndate);
                countBook.NewPrice = this.CheckNewPrice(countBook.Book.Price, countBook.PromotionDiscount);
            }

            viewModel.Books      = countBooks;
            viewModel.BooksCount = this.CheckAllBooksCount(countBooks);
            return(viewModel);
        }
コード例 #2
0
        public ActionResult Create()
        {
            string code = _purchaseManager.GetLastPurchaseCode();


            string year = DateTime.Parse(DateTime.Now.ToString()).Year.ToString();

            if (code == null)
            {
                code = year + "-0001";
            }
            else
            {
                string[] afterSplit = code.Split('-');

                string serialNo = afterSplit[afterSplit.Length - 1];
                int    number   = int.Parse(serialNo);
                code = year + "-" + (++number).ToString("D" + serialNo.Length);
            }
            PurchaseDetailsViewModel model = new PurchaseDetailsViewModel
            {
                Suppliers  = _supplierManager.GetAll(),
                Categories = _categoryManager.GetAll(),
                //PurchaseDetail = new PurchaseDetail(),
                Code = code
            };

            return(View(model));
        }
コード例 #3
0
        public ActionResult AddPurchase()
        {
            PurchaseViewModel        purchaseViewModel        = new PurchaseViewModel();
            PurchaseDetailsViewModel purchaseDetailsViewModel = new PurchaseDetailsViewModel();

            purchaseViewModel.SupplierSelectListItems = _supplierManager
                                                        .GetAll()
                                                        .Select(c => new SelectListItem()
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            }).ToList();
            //purchaseViewModel.CategorySelectListItems = _categoryManager
            //                                                   .GetAll()
            //                                                   .Select(c => new SelectListItem()
            //                                                   {
            //                                                       Value = c.Id.ToString(),
            //                                                       Text = c.Name
            //                                                   }).ToList();
            //purchaseViewModel.ProductSelectListItems = _productManager
            //                                                   .GetAll()
            //                                                   .Select(c => new SelectListItem()
            //                                                   {
            //                                                       Value = c.Id.ToString(),
            //                                                       Text = c.Name
            //                                                   }).ToList();

            return(View(purchaseViewModel));
        }
コード例 #4
0
        public ActionResult AddPurchase(PurchaseViewModel purchaseViewModel)
        {
            Purchase purchase = Mapper.Map <Purchase>(purchaseViewModel);

            _purchaseManager.Add(purchase);
            PurchaseDetailsViewModel purchaseDetailsViewModel = new PurchaseDetailsViewModel();

            purchaseViewModel.SupplierSelectListItems = _supplierManager
                                                        .GetAll()
                                                        .Select(c => new SelectListItem()
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            }).ToList();
            purchaseDetailsViewModel.CategorySelectListItems = _categoryManager
                                                               .GetAll()
                                                               .Select(c => new SelectListItem()
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            }).ToList();
            ViewBag.CategoryId          = purchaseDetailsViewModel.CategorySelectListItems;
            purchaseViewModel.Purchases = _purchaseManager.GetAllPurchase();

            return(View(purchaseViewModel));
        }
コード例 #5
0
        public ActionResult EditPurchaseDetails(PurchaseDetailsViewModel purchaseDetailsViewModel)
        {
            string message = "";

            PurchaseDetails purchaseDetails = Mapper.Map <PurchaseDetails>(purchaseDetailsViewModel);

            purchaseDetailsViewModel.CategorySelectListItems = _categoryManager
                                                               .GetAll()
                                                               .Select(c => new SelectListItem()
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            }).ToList();
            ViewBag.CategoryId = purchaseDetailsViewModel.CategorySelectListItems;


            if (_purchaseManager.Update(purchaseDetails))
            {
                message = "Updated Successfully..";
            }
            else
            {
                message = "No Change Your Update Information";
            }

            purchaseDetailsViewModel.PurchaseDetails = _purchaseManager.GetAll().Where(c => c.Id == purchaseDetailsViewModel.Id).ToList();
            ViewBag.Message = message;
            return(View(purchaseDetailsViewModel));
        }
コード例 #6
0
        public async Task <IActionResult> CreatePurchase(int adId, int serviceId)
        {
            var model = new PurchaseDetailsViewModel();

            model.PurhcaseDetail.AdId       = adId;
            model.PurhcaseDetail.ServicesId = serviceId;
            return(View("Details", model));
        }
コード例 #7
0
        public ActionResult Info(List <Production> ProductionList, int ShipmentID)
        {
            PurchaseDetailsViewModel m = new PurchaseDetailsViewModel();

            m.Production = MarketingActivity(ProductionList);
            m.Fee        = calculateFee(ProductionList, ShipmentID);
            m.totalAmt   = ProductionList.Sum(x => x.DiscountPrice * x.Count) + m.Fee.Sum();
            return(View(m));
        }
コード例 #8
0
        public async Task YourMethodName(PurchaseDetailsViewModel model)
        {
            string requestURL = "/path/{Parameter}";
            var    httpMethod = BaseNetworkAccessEnum.Get;
            var    parameters = new Dictionary <string, ParameterTypedValue>()
            {
                //{"Parameter", model.Property},
            };

            await _NetworkInterface(requestURL, parameters, httpMethod);
        }
コード例 #9
0
        public async Task <IActionResult> GetPurchase(int id)
        {
            var model            = new PurchaseDetailsViewModel();
            var operationDetails = await _purchasesService.GetPurchaseById(id);

            if (!operationDetails.Succedeed)
            {
                return(View("Index", model.StatusMessage = operationDetails.Message));
            }

            return(View("Details", model));
        }
コード例 #10
0
        //Show Purchase Details
        public ActionResult PurchaseDetails(int id)
        {
            PurchaseViewModel purchaseViewModel = new PurchaseViewModel();

            purchaseViewModel.Purchases = _purchaseManager.GetAllPurchase().Where(c => c.Id == id).ToList();
            ViewBag.Category            = _categoryManager.GetAll();

            PurchaseDetailsViewModel purchaseDetailsViewModel = new PurchaseDetailsViewModel();

            purchaseDetailsViewModel.PurchaseDetails = _purchaseManager.GetAll().Where(c => c.PurchaseId == id).ToList();
            ViewBag.Details = purchaseDetailsViewModel.PurchaseDetails;
            return(View(purchaseViewModel));
        }
コード例 #11
0
        public async Task <IActionResult> SaveUpdatedPurchase(PurchaseDetailsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Details", model));
            }

            var operationDetails = await _purchasesService.UpdatePurchase(model.PurhcaseDetail);

            if (!operationDetails.Succedeed)
            {
                return(View("Details", model.StatusMessage = operationDetails.Message));
            }

            return(RedirectToAction("Index"));
        }
コード例 #12
0
        // GET: Admin/Purchases/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                throw new Exception("Invalid URL - promotion's id can not be null");
            }

            PurchaseDetailsViewModel viewModel = this.purchaseService.GetDetails(id);

            if (viewModel == null)
            {
                throw new Exception($"Invalid URL - there is no promotion with id {id}");
            }

            return(View(viewModel));
        }
コード例 #13
0
        // Sales Detials
        public ActionResult SalesDetails(int id)
        {
            //PurchaseViewModel purchaseViewModel = new PurchaseViewModel();
            SaleViewModel saleViewModel = new SaleViewModel();

            //purchaseViewModel.Purchases = _purchaseManager.GetAllPurchase().Where(c => c.Id == id).ToList();
            saleViewModel.Sales = _salesManager.GetAll().Where(c => c.Id == id).ToList();
            ViewBag.Category    = _categoryManager.GetAll();

            PurchaseDetailsViewModel purchaseDetailsViewModel = new PurchaseDetailsViewModel();
            SaleDetailsViewModel     saleDetialsViewModel     = new SaleDetailsViewModel();

            //purchaseDetailsViewModel.PurchaseDetails = _purchaseManager.GetAll().Where(c => c.PurchaseId == id).ToList();
            saleDetialsViewModel.SaleDetails = _salesManager.GetAllSaleDetails().Where(c => c.SaleId == id).ToList();
            ViewBag.Details = saleDetialsViewModel.SaleDetails;
            return(View(saleViewModel));
        }
コード例 #14
0
        public ActionResult EditPurchaseDetails(int id)
        {
            PurchaseDetailsViewModel purchaseDetailsViewModel = new PurchaseDetailsViewModel();

            purchaseDetailsViewModel.PurchaseDetails = _purchaseManager.GetAll().Where(c => c.Id == id).ToList();

            //PurchaseDetailsViewModel purchaseDetailsViewModel = new PurchaseDetailsViewModel();
            purchaseDetailsViewModel.CategorySelectListItems = _categoryManager
                                                               .GetAll()
                                                               .Select(c => new SelectListItem()
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            }).ToList();
            ViewBag.CategoryId = purchaseDetailsViewModel.CategorySelectListItems;
            return(View(purchaseDetailsViewModel));
        }
コード例 #15
0
        public ActionResult Edit(int?id)

        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var purchase = _db.Purchase.Find(id);

            if (purchase == null)
            {
                return(HttpNotFound());
            }

            var datos = _db.TiposProducto.ToList();


            var model = (from head in _db.Purchase
                         join det in _db.PurchaseDetails
                         on head.Id equals det.PurchaseId
                         where head.Id == purchase.Id
                         select new PurchaseDetailsViewModel
            {
                Header = head,
                Detail = det
            });

            PurchaseDetailsViewModel nuevo = new PurchaseDetailsViewModel();

            foreach (var item in model)
            {
                nuevo.Header = item.Header;
                nuevo.Detail = item.Detail;
            }


            @ViewData["TiposProducto"] = datos;

            return(View(purchase));
        }
コード例 #16
0
        public async Task <IActionResult> CreatePurchase(int adId, int serviceId, int serviceActiveId)
        {
            var model = new PurchaseDetailsViewModel()
            {
                PurhcaseDetail = new PurchaseDTO(), SelectedService = new ServiceDTO()
            };

            var service = await _servicesService.GetServiceById(serviceId);

            var serviceActiveTimes = service.Property.ServiceActiveTimes.Where(x => x.ServiceActiveTimeId == serviceActiveId).FirstOrDefault();

            model.PurhcaseDetail.AdId                = adId;
            model.PurhcaseDetail.StartDateService    = DateTime.Now;
            model.PurhcaseDetail.EndDateService      = DateTime.Now.AddDays(serviceActiveTimes.DaysOfActiveService);
            model.PurhcaseDetail.ServicesId          = serviceId;
            model.PurhcaseDetail.TotalCost           = serviceActiveTimes.Cost;
            model.PurhcaseDetail.ServiceActiveTimeId = serviceActiveId;
            model.SelectedService = service.Property;
            model.SelectedService.SelectedServiceActiveDaysId = serviceActiveId;

            return(View("Details", model));
        }