public IActionResult Update([FromBody] LanguageInputViewModel obj) { try { _context.Session.BeginTransaction(); _context.Update <Language>(g => g.Id == obj.Id, a => new Language { Key = obj.Key, Page = obj.Page, Vi = obj.Vi, En = obj.En }); _context.Session.CommitTransaction(); return(Json(new ActionResultDto())); } catch (Exception e) { if (_context.Session.IsInTransaction) { _context.Session.RollbackTransaction(); } return(Json(new ActionResultDto { Error = e.Message })); } }
public IActionResult Create([FromBody] LanguageInputViewModel obj) { if (_context.Query <Language>().Where(g => g.Key == obj.Key).Count() > 0) { return(Json(new ActionResultDto { Success = false, Error = new { Code = 401, Message = "Tạo ngôn ngữ thất bại.", Details = "Tên từ khoá đã có !" } })); } return(Json(new ActionResultDto { Result = _context.Insert(new Language(obj)) })); }