public async Task <InvoiceBindingModel> SetInvoiceNumber(InvoiceBindingModel model) { if (!ModelState.IsValid) { TempData.AddErrorMessage(WrongInput); model.Id = 0; return(model); } var returnModel = await this.consumables.SentNumberAsync(model); if (returnModel == null) { TempData.AddErrorMessage(WrongInput); model.Id = 0; return(model); } return(returnModel); }
public async Task <InvoiceBindingModel> SentNumberAsync(InvoiceBindingModel model) { var monthlyRent = await this.Db.FindAsync <MonthlyPaymentRent>(model.Id); if (monthlyRent == null) { return(null); } monthlyRent.InvoiceNumber = model.InvoiceNumber; this.Db.Update(monthlyRent); try { await this.Db.SaveChangesAsync(); } catch (Exception) { return(null); } return(model); }