public ActionResult WriteNote(string Pattern, int id, string TypeView) { Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany; IInvoiceService IInvSrv = InvServiceFactory.GetService(Pattern, currentCom.id); IInvoice Einv = IInvSrv.Getbykey <IInvoice>(id); //thong tin view model WriteNoteModel model = new WriteNoteModel(); model.id = id; model.pattern = Pattern; model.TypeView = TypeView; if (string.IsNullOrEmpty(Einv.Note)) { model.Note = ""; } else { model.Note = Einv.Note; } return(View(model)); }
public ActionResult WriteNote(WriteNoteModel model) { if (model.id <= 0) { throw new HttpRequestValidationException(); } Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany; IInvoiceService IInvSrv = InvServiceFactory.GetService(model.pattern, currentCom.id); IInvoice EInvoiceEditNote = IInvSrv.Getbykey <IInvoice>(model.id); try { EInvoiceEditNote.Note = model.Note; IInvSrv.Save(EInvoiceEditNote); IInvSrv.CommitChanges(); log.Info("Writenote EInvoice by: " + HttpContext.User.Identity.Name); Messages.AddFlashMessage("Ghi chú thành công!"); } catch (Exception ex) { log.Error(" WriteNote-" + ex.Message); Messages.AddErrorFlashMessage("Ghi chú không thành công!"); } if (model.TypeView == "0") { return(RedirectToAction("Index", new { Pattern = model.pattern, Serial = EInvoiceEditNote.Serial })); } else if (model.TypeView == "1") { return(RedirectToAction("ReplaceInvIndex", "Adjust", new { pattern = model.pattern, Serial = EInvoiceEditNote.Serial })); } else { return(RedirectToAction("AdjustInvIndex", "Adjust", new { pattern = model.pattern, Serial = EInvoiceEditNote.Serial })); } }