public ActionResult Purchase(int id) { var carRepo = VehicleRepositoryFactory.GetRepository(); var purchaseRepo = PurchaseRepositoryFactory.GetRepository(); var vehicle = carRepo.GetVehicle(id); var model = new PurchaseViewModel(); model.Vehicle = vehicle; model.PaymentMethods = new SelectList(purchaseRepo.GetAllPaymentTypes(), "PaymentMethodId", "PaymentName"); return(View(model)); }
public ActionResult Purchased(PurchaseViewModel model) { var repo = PurchaseRepositoryFactory.GetRepository(); repo.SaveCustomerInfo(model.Customer); model.Reciept.CustomerId = model.Customer.CustomerId; model.Reciept.VehicleId = model.Vehicle.VehicleId; model.Reciept.EmployeeId = 1; model.Reciept.PaymentMethodId = model.Payment.PaymentMethodId; model.Reciept.Date = DateTime.Now; repo.SavePurchase(model.Reciept); repo.PurchaseVehicle(model.Vehicle.VehicleId); return(RedirectToAction("Index")); }
public IHttpActionResult Search(string userID, DateTime?fromDate, DateTime?toDate) { var repo = PurchaseRepositoryFactory.GetRepository(); try { var parameters = new SalesSearchParameters() { UserID = userID, FromDate = fromDate, ToDate = toDate }; var result = repo.SearchSales(parameters); return(Ok(result)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public ActionResult Purchase(PurchaseAddViewModel model) { if (Request.IsAuthenticated) { model.Purchase.UserID = AuthorizeUtilities.GetUserId(this); } if (ModelState.IsValid) { var customerRepo = CustomerRepositoryFactory.GetRepository(); var purchaseRepo = PurchaseRepositoryFactory.GetRepository(); try { customerRepo.Insert(model.Customer); model.Purchase.CustomerID = model.Customer.CustomerID; model.Purchase.VehicleID = model.VehicleDetails.VehicleID; purchaseRepo.Insert(model.Purchase); return(RedirectToAction("Index")); } catch (Exception ex) { throw ex; } } else { var repo = VehicleRepositoryFactory.GetRepository(); var staterepo = StateRepositoryFactory.GetRepository(); model.VehicleDetails = repo.GetDetails(model.VehicleDetails.VehicleID); model.Purchase.VehicleID = model.VehicleDetails.VehicleID; model.SetStateItems(staterepo.GetAll()); return(View(model)); } }