public ReceiptViewModel(Receipt rec) { Id = rec.Id.ToString("D6"); Adress = rec.Order.AdresShipping.FullAdress; Distance = rec.Order.Distance; PhoneNumber = rec.Order.User.PhoneNumber; ShippingCost = rec.ShippingCost; ReceiptStatus = rec.Status.ToString(); ShippingType = rec.Order.ShippingType; }
public async Task CreateReceipt(Receipt rec) { _db.Entry(rec).State = EntityState.Added; await Save(); }
public async Task<ActionResult> CreateReceipt(string id, string returnUrl) { var order = await OrderManager.FindAsync(id); var tariffModel = await GetTariffModel(order); var rec = new Receipt { Date = DateTime.Now, OrderId = order.Id, Order = order, ShippingCost = tariffModel.Tariff, Status = ReceiptStatus.Created }; await CalculateProductCount(order.Id); if (!ModelState.IsValid) return RedirectToAction("Edit", order.Id); await OrderManager.CreateReceipt(rec); return RedirectToAction("DetailReceipt", new { id = rec.Id }); }