public async Task <IActionResult> CreateSale(SaleViewModel sale) { var saleService = new SaleService(); var createSale = _mapper.Map <SaleViewModel>(await saleService.AddSale(sale)); return(View("Views/Welcome/Purchase.cshtml")); }
private void ContinueSaleCreation(ActionExecutionContext context, Guid employeeId) { context.Out.Write(ConsoleColor.Blue, "Введите сумму продажи: "); var summ = context.In.ReadDecimal(); var employee = EmployeeService.GetEmployeeById(employeeId); context.Out.Write(ConsoleColor.Blue, "Введите дату продажи (dd-mm-yyyy): "); var date = context.In.ReadLine(); DateTime dateResult; DateTime.TryParse(date, out dateResult); SaleService.AddSale(employee, dateResult, summ); }
public void AddSalePresenter() { SaleRequest saleRequest = new SaleRequest(); saleRequest.Sale = _view.sale; SaleResponse saleResponse = saleService.AddSale(saleRequest); if (saleResponse.Success) { _view.SuccessSale("Se inserto la venta"); } else { _view.ErrorSale(string.Format("{0}", saleResponse.Exception.Message)); } }
public JsonResult Create([Bind(Include = "ClientId,ProductId,SellerId,Cost,Date")] SaleCreateView createdSale) { if (ModelState.IsValid) { var saleForInsert = Mapper.Map <Sale>(createdSale); try { saleService.AddSale(saleForInsert); return(Json(new { result = true, message = "Sale added" })); } catch (Exception e) { return(Json(new { result = false, message = "Server error, sorry" })); } } return(Json(new { result = false, message = "Model is invalid" })); }