public IActionResult Create([Bind("CheckId,CustomerId,EmployeeId,BuyingDate,TotalPrice")] FurnitureSale furnitureSale) { if (ModelState.IsValid) { _furnituresalerepository.Create(furnitureSale); return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_customerrepository.GetAll(), "CustomerId", "CustFullName", furnitureSale.CustomerId); ViewData["EmployeeId"] = new SelectList(_employeerepository.GetAll(), "EmployeeId", "EmpFullName", furnitureSale.EmployeeId); return(View(furnitureSale)); }
public FurnitureSale FormBillForClientWithDiscount() { string directory = Directory.GetCurrentDirectory() + "\\tempFiles\\"; DataContractJsonSerializer jsonFormatter = new DataContractJsonSerializer(typeof(int)); int?customerId = null; int employeeId = 0; using (FileStream fs = new FileStream(directory + "Customer.json", FileMode.Open)) { customerId = (int)jsonFormatter.ReadObject(fs); } using (FileStream fs = new FileStream(directory + "Seller.json", FileMode.Open)) { employeeId = (int)jsonFormatter.ReadObject(fs); } decimal totalSum = CalculateTotalSumOfBillWithDiscount(customerId); FurnitureSale customerCheck = new FurnitureSale { BuyingDate = DateTime.Now, CustomerId = customerId, EmployeeId = employeeId, TotalPrice = totalSum }; furnitureSaleRepository.Create(customerCheck); IEnumerable <CheckDetails> list = checkDetailsRepository.GetMultipleCheckDetailsInfo(m => m.CheckId == null); List <CheckDetails> listOfBill = list.ToList(); List <FurnitureInStorage> furnitureInStorageList = new List <FurnitureInStorage>(); for (int i = 0; i < listOfBill.Count; i++) { FurnitureInStorage furniture = furnitureInStorageRepository.GetFurnitureInStorageForBillById(listOfBill[i].FurnitureId); furnitureInStorageList.Add(furniture); listOfBill[i].CheckId = customerCheck.CheckId; furnitureInStorageList[i].QuantityInStorage -= listOfBill[i].QuantitySelected; checkDetailsRepository.Update(listOfBill[i]); furnitureInStorageRepository.Update(furnitureInStorageList[i]); } return(furnitureSaleRepository.GetInfoAboutConfirmedBill(customerCheck)); }
public IActionResult Search([Bind("CheckId")] FurnitureSale checkInfo) { return(RedirectToAction("IndexSingle", new { checkId = checkInfo.CheckId })); }
public IActionResult Search([Bind("BuyingDate")] FurnitureSale checkInfo) { return(RedirectToAction("IndexSingle", new { buyingDate = checkInfo.BuyingDate })); }