/// <summary> /// Cập nhật thông tin ErrorMgs /// Author : HoangNM - 14/04/2019 - create /// </summary> /// <param name="errorMgs">thông tin về ErrorMgs muốn thay đổi</param> /// <returns>Trả về các thông tin khi cập nhật loại truyện, Excetion nếu có lỗi</returns> public ResponseInfo UpadateErrorMgs(ErrorMgs errorMgs) { DbContextTransaction transaction = context.Database.BeginTransaction(); ResponseInfo response = new ResponseInfo(); try { context.ErrorMsgs.Where(x => x.Id == errorMgs.Id && !x.DelFlag) .Update(x => new TblErrorMgs { Type = errorMgs.Type, mgs = errorMgs.Msg }); context.SaveChanges(); response.IsSuccess = true; transaction.Commit(); var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.CapNhatDuLieuThanhCong); response.TypeMsgError = errorMsg.Type; response.MsgError = errorMsg.Msg; return(response); } catch (Exception e) { response.IsSuccess = false; transaction.Rollback(); throw e; } }
/// <summary> /// Thêm ErrorMgs /// Author : HoangNM - 14/04/2019 - create /// </summary> /// <param name="errorMgs">errorMgs cần thêm</param> /// <returns>Trả về các thông tin khi cập nhật chu kỳ truyện, Excetion nếu có lỗi</returns> public ResponseInfo ThemErrorMgs(ErrorMgs errorMgs) { DbContextTransaction transaction = context.Database.BeginTransaction(); try { ResponseInfo response = new ResponseInfo(); errorMgs.Id = context.ErrorMsgs.Count() == 0 ? 1 : context.ErrorMsgs.Max(x => x.Id) + 1; context.ErrorMsgs.Add(new TblErrorMgs { Type = errorMgs.Type, mgs = errorMgs.Msg }); context.SaveChanges(); response.ThongTinBoSung1 = errorMgs.Id + ""; transaction.Commit(); var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.ThemDuLieuThanhCong); response.TypeMsgError = errorMsg.Type; response.MsgError = errorMsg.Msg; return(response); } catch (Exception e) { transaction.Rollback(); throw e; } }
public ResponseInfo UpdateErrorMsg(ErrorMgs data) { ResponseInfo response = new ResponseInfo(); try { response = new QuanLyErrorMsgModel().UpadateErrorMgs(data); } catch (Exception e) { response.Code = (int)ConstantsEnum.CodeResponse.ServerError; var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.ServerError); response.TypeMsgError = errorMsg.Type; response.MsgError = errorMsg.Msg; response.ThongTinBoSung1 = e.Message; } return(response); }