public JsonResult Update([FromBody] AdLanguage obj) { //_logger.LogInformation(LoggingEvents.LogDb, "Update language"); var msg = new JMessage() { Error = false }; try { var caption = _context.AdLanguages.FirstOrDefault(x => x.Culture == obj.Culture && x.LanguageId != obj.LanguageId); if (caption == null) { if (obj.IsDefault == true) { foreach (var item in _context.AdLanguages.Where(w => w.IsDefault == true)) { item.IsDefault = false; } } _context.AdLanguages.Update(obj); _context.Entry(obj).State = EntityState.Modified; var a = _context.SaveChanges(); //msg.Title = "Update item successfully!"; msg.Title = String.Format(CommonUtil.ResourceValue("MSG_UPDATE_SUCCESS"), CommonUtil.ResourceValue("LANGUAGE")); //_logger.LogInformation(LoggingEvents.LogDb, "Update language successfully"); } else { msg.Error = true; //msg.Title = "Item is exists!"; msg.Title = String.Format(CommonUtil.ResourceValue("ERR_EXIST"), CommonUtil.ResourceValue("LANGUAGE")); //_logger.LogError(LoggingEvents.LogDb, "Update language fail"); return(Json(msg)); } } catch (Exception) { msg.Error = true; //msg.Title = "Update item fail!"; msg.Title = String.Format(CommonUtil.ResourceValue("MSG_UPDATE_FAIL"), CommonUtil.ResourceValue("LANGUAGE")); //_logger.LogError(LoggingEvents.LogDb, "Update language fail"); } return(Json(msg)); }
public object Resort([FromBody] List <AdOrganization> model) { var msg = new JMessage() { Error = false }; try { foreach (var item in model) { _context.AdOrganizations.Attach(item); _context.Entry(item).Property(x => x.OrgOrd).IsModified = true; _context.SaveChanges(); } msg.Title = String.Format(CommonUtil.ResourceValue("MSG_SORT_SUCCESS"), CommonUtil.ResourceValue("ORGANIZATIONS").ToLower()); } catch (Exception) { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("MSG_SORT_FAIL"), CommonUtil.ResourceValue("ORGANIZATIONS").ToLower()); } return(Json(msg)); }
public object Resort([FromBody] List <AdApplication> model) { var msg = new JMessage() { Error = false }; try { foreach (var item in model) { _context.AdApplications.Attach(item); _context.Entry(item).Property(x => x.Ord).IsModified = true; _context.SaveChanges(); } msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_SORT_SUCCESS"), CommonUtil.ResourceValue("ADM_APP_LBL_APP")); //"Sắp xếp các khoản mục thành công."; } catch (Exception) { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_SORT_FAIL"), CommonUtil.ResourceValue("ADM_APP_LBL_APP")); //"Có lỗi khi sắp xếp khoản mục"; } return(Json(msg)); }