Exemplo n.º 1
0
        /// <summary>
        /// Thêm chu kỳ phát hành
        /// Author       :   HoangNM - 13/03/2019 - create
        /// </summary>
        /// <param name="chuKy">chu kỳ phát hành sẽ 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 ThemChuKy(ChuKy chuKy)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();

            try
            {
                ResponseInfo response = new ResponseInfo();

                int id = context.ChuKyPhatHanhs.Count() == 0 ? 1 : context.ChuKyPhatHanhs.Max(x => x.Id) + 1;
                context.ChuKyPhatHanhs.Add(new TblChuKy
                {
                    TenChuKy = chuKy.TenChuKy
                });
                context.SaveChanges();
                response.ThongTinBoSung1 = 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;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Cập nhật thông tin chu kỳ phát hành
        /// Author       :   HoangNM - 13/03/2019 - create
        /// </summary>
        /// <param name="chuKyTruyen">thông tin về chu kỳ truyện 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 UpadateChuKy(ChuKy chuKyTruyen, int id)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();
            ResponseInfo         response    = new ResponseInfo();

            try
            {
                context.ChuKyPhatHanhs.Where(x => x.Id == id && !x.DelFlag)
                .Update(x => new TblChuKy
                {
                    TenChuKy = chuKyTruyen.TenChuKy,
                });
                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;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Lấy thông tin 1 chu kỳ phát hành
 /// Author       :   HoangNM - 13/03/2019 - create
 /// </summary>
 /// <returns>lấy ra chu kỳ truyện theo id. Exception nếu có lỗi</returns>
 public ChuKy LoadChuKy(int id)
 {
     try
     {
         ChuKy    chuKy    = new ChuKy();
         TblChuKy tblChuKy = context.ChuKyPhatHanhs.FirstOrDefault(x => x.Id == id && !x.DelFlag);
         if (tblChuKy != null)
         {
             chuKy.Id       = tblChuKy.Id;
             chuKy.TenChuKy = tblChuKy.TenChuKy;
         }
         return(chuKy);
     }
     catch (Exception e)
     {
         throw e;
     }
 }