public void CanCreateSale2() { ISalesInfoRepository repo = RepoFactory.CreateSaleInfoRepo(); SaleInfo sale = new SaleInfo() { City = "City", ZipCode = 12345, Name = "TestSale", Email = "*****@*****.**", PurchasePrice = 100M, Phone = "123-123-1234", State = "MN", StreetOne = "Street one", PurchaseDate = DateTime.Today, StreetTwo = "", PurchaseType = "Bank", UserId = "0000-000000-0000000-0000000", VehicleId = 300, }; var result = repo.Create(sale); Assert.AreEqual(sale, result); }
public HttpResponseMessage GetSalesReport(JObject searchInput) { JavaScriptSerializer jr = new JavaScriptSerializer(); ISalesInfoRepository repo = RepoFactory.CreateSaleInfoRepo(); var response = new HttpResponseMessage(); try { SalesReportJsonModel searchData = jr.Deserialize <SalesReportJsonModel>(searchInput.ToString()); List <SaleReport> reports = repo.Sales(searchData.UserId, searchData.FromDate, searchData.ToDate); response.Content = new StringContent(jr.Serialize(reports)); response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/json"); } catch (Exception) { response.StatusCode = (HttpStatusCode)400; } return(response); }
public ActionResult Purchase(SalesPurchaseViewModel model) { if (model.Sale.PurchasePrice < (model.Vehicle.SalePrice * 0.95M) || model.Sale.PurchasePrice > model.Vehicle.MSRP) { ModelState.AddModelError("error", "The purchase price can not be less than 5% of the sale price or greater than the MSRP"); } if (ModelState.IsValid) { ISalesInfoRepository repo = RepoFactory.CreateSaleInfoRepo(); IVehicleRepository vehicleRepo = RepoFactory.CreateVehicleRepo(); repo.Create(model.Sale); vehicleRepo.ChangeToSold(model.Sale.VehicleId); return(RedirectToAction("Index")); } IVehicleRepository vrepo = RepoFactory.CreateVehicleRepo(); model.Vehicle = vrepo.GetById(model.Sale.VehicleId); model.ImageFilePath = HelpMethods.Helpers.GetImageFilePath(model.Sale.VehicleId); return(View(model)); }