/// <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;
            }
        }
        /// <summary>
        /// Thêm phân quyền
        /// Author       :   HoangNM - 16/04/2019 - create
        /// </summary>
        /// <param name="phanQuyen">phân quyền sẽ thêm</param>
        /// <returns>Trả về các thông tin khi thêm quyền vào db, Excetion nếu có lỗi</returns>
        public ResponseInfo ThemPhanQuyen(NewPhanQuyen phanQuyen)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();

            try
            {
                ResponseInfo response = new ResponseInfo();

                int     id        = context.PhanQuyens.Count() == 0 ? 1 : context.PhanQuyens.Max(x => x.Id) + 1;
                decimal TongQuyen = 0;
                foreach (int i in phanQuyen.Id_QuyenList)
                {
                    TongQuyen += context.Quyens.FirstOrDefault(x => x.Id == i && !x.DelFlag).BitQuyen;
                }
                context.PhanQuyens.Add(new TblPhanQuyen
                {
                    TenVaiTro = phanQuyen.TenVaiTro,
                    TongQuyen = TongQuyen
                });
                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;
            }
        }
        public ResponseInfo DanhSachNhomDichCuaTaiKhoan()
        {
            ResponseInfo response = new ResponseInfo();
            var          kt       = Convert.ToInt64(new GetPermission().GetQuyen("TEAMMEM_LIS")) & Convert.ToInt64(Common.Common.GetTongQuyen());

            if (kt != 0)
            {
                try
                {
                    response.Data      = new QuanLyThanhVienTrongNhomModel().GetDanhSachNhomDichCuaTaiKhoan();
                    response.IsSuccess = true;
                }
                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;
                }
            }
            else
            {
                var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.BanKhongDuQuyen);
                response.TypeMsgError = errorMsg.Type;
                response.MsgError     = errorMsg.Msg;
            }


            return(response);
        }
        public ResponseInfo DeleteErrorMsg(int id)
        {
            ResponseInfo response = new ResponseInfo();

            try
            {
                bool deleted = new QuanLyErrorMsgModel().DeleteErrorMgs(id);
                if (deleted)
                {
                    response.IsSuccess = true;
                    var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.XoaDuLieuThanhCong);
                    response.TypeMsgError = errorMsg.Type;
                    response.MsgError     = errorMsg.Msg;
                }
                else
                {
                    var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.XoaDuLieuThatBai);
                    response.TypeMsgError = errorMsg.Type;
                    response.MsgError     = errorMsg.Msg;
                }
            }
            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);
        }
Esempio n. 5
0
        /// <summary>
        /// Cập nhật thông tin nhóm dịch
        /// Author       :   HoangNM - 18/03/2019 - create
        /// </summary>
        /// <param name="nhomDich">thông tin về nhóm dịch muốn thay đổi</param>
        /// <returns>Trả về các thông tin khi cập nhật nhóm dịch, Excetion nếu có lỗi</returns>
        public ResponseInfo UpadateNhomDich(NhomDich nhomDich, int id)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();
            ResponseInfo         response    = new ResponseInfo();

            try
            {
                context.NhomDiches.Where(x => x.Id == id && !x.DelFlag)
                .Update(x => new TblNhomDich
                {
                    TenNhomDich = nhomDich.TenNhomDich,
                    Logo        = nhomDich.Logo,
                    MoTa        = nhomDich.MoTa
                });
                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;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Thêm nhóm dịch
        /// Author       :   HoangNM - 18/03/2019 - create
        /// </summary>
        /// <param name="nhomDich">nhóm dịch sẽ thêm</param>
        /// <returns>Trả về các thông tin khi cập nhật nhóm dịch, Excetion nếu có lỗi</returns>
        public ResponseInfo ThemNhomDich(NhomDich nhomDich)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();

            try
            {
                ResponseInfo response = new ResponseInfo();
                int          Id       = Common.Common.GetAccount().Id;
                var          TaiKhoan = context.TaiKhoans.FirstOrDefault(x => x.Id == Id && !x.DelFlag);
                if (TaiKhoan.Id_PhanQuyen == 5 || TaiKhoan.Id_PhanQuyen == 4)
                {
                    TaiKhoan.Id_PhanQuyen = 3;
                }
                int id   = context.NhomDiches.Count() == 0 ? 1 : context.NhomDiches.Max(x => x.Id) + 1;
                var nhom = context.NhomDiches.Add(new TblNhomDich
                {
                    TenNhomDich = nhomDich.TenNhomDich,
                    MoTa        = nhomDich.MoTa,
                    Logo        = nhomDich.Logo
                });
                TaiKhoan.Id_NhomDich = nhom.Id;
                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;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Thêm tác giả
        /// Author       :   HoangNM - 16/03/2019 - create
        /// </summary>
        /// <param name="tacGia">tác giả sẽ thêm</param>
        /// <returns>Trả về các thông tin khi thêm tác giả, Excetion nếu có lỗi</returns>
        public ResponseInfo ThemTacGia(TacGia tacGia)
        {
            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.TacGias.Add(new TblTacGia
                {
                    TenTacGia = tacGia.TenTacGia
                });
                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;
            }
        }
        public ResponseInfo Get(int id)
        {
            ResponseInfo response = new ResponseInfo();

            try
            {
                var kt = Convert.ToInt64(new GetPermission().GetQuyen("ACCOUNT_GET")) & Convert.ToInt64(Common.Common.GetTongQuyen());
                if (kt != 0)
                {
                    response.Data      = new QuanLyTaiKhoanModel().LoadTaiKhoan(id);
                    response.IsSuccess = true;
                }
                else
                {
                    var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.BanKhongDuQuyen);
                    response.TypeMsgError = errorMsg.Type;
                    response.MsgError     = errorMsg.Msg;
                }
            }
            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);
        }
Esempio n. 9
0
        /// <summary>
        /// Thêm nhóm dịch
        /// Author       :   HoangNM - 18/03/2019 - create
        /// </summary>
        /// <param name="nhomDich">nhóm dịch sẽ thêm</param>
        /// <returns>Trả về các thông tin khi cập nhật nhóm dịch, Excetion nếu có lỗi</returns>
        public ResponseInfo ThemThanhVienVaoNhom(AddThanhVien data)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();

            try
            {
                ResponseInfo response = new ResponseInfo();
                int          Id       = Common.Common.GetAccount().IdNhom;
                var          TaiKhoan = context.TaiKhoans.FirstOrDefault(x => x.Username == data.Username && !x.DelFlag);
                if (TaiKhoan == null)
                {
                    var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.UserNameKhongTonTai);
                    response.TypeMsgError = errorMsg.Type;
                    response.MsgError     = errorMsg.Msg;
                    response.Code         = 400;
                    return(response);
                }
                else
                {
                    TaiKhoan.Id_NhomDich = Id;
                    context.SaveChanges();
                    transaction.Commit();
                    var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.ThemThanhvienThanhCong);
                    response.TypeMsgError = errorMsg.Type;
                    response.MsgError     = errorMsg.Msg;
                    return(response);
                }
            }
            catch (Exception e)
            {
                transaction.Rollback();
                throw e;
            }
        }
        /// <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;
            }
        }
 public ResponseInfo ThemChuongTruyen(ChuongCuaTruyen data)
 {
     ResponseInfo response = new ResponseInfo();
     try
     {
         var kt = Convert.ToInt64(new GetPermission().GetQuyen("CHAPTER_CRE")) & Convert.ToInt64(Common.Common.GetTongQuyen());
         if (kt != 0)
         {
             response = new QuanLyChuongTruyenModel().ThemChuongTruyen(data);
         }
         else
         {
             var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.BanKhongDuQuyen);
             response.TypeMsgError = errorMsg.Type;
             response.MsgError = errorMsg.Msg;
         }
             
     }
     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;
 }
Esempio n. 12
0
        /// <summary>
        /// Thêm quyền
        /// Author       :   HoangNM - 16/04/2019 - create
        /// </summary>
        /// <param name="quyen">quyền sẽ thêm</param>
        /// <returns>Trả về các thông tin khi thêm quyền vào db, Excetion nếu có lỗi</returns>
        public ResponseInfo ThemQuyen(NewQuyen quyen)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();

            try
            {
                ResponseInfo response = new ResponseInfo();

                int id = context.Quyens.Count() == 0 ? 1 : context.PhanQuyens.Max(x => x.Id) + 1;
                context.Quyens.Add(new TblQuyen
                {
                    TenQuyen = quyen.TenQuyen,
                    BitQuyen = quyen.BitQuyen
                });
                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;
            }
        }
        /// <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;
            }
        }
Esempio n. 14
0
        //Lấy lại mật khẩu
        public ResponseInfo ForgotPassword(SendEMail email)
        {
            ResponseInfo result = new ResponseInfo();

            try
            {
                var    taikhoan = context.TaiKhoans.FirstOrDefault(x => x.Email == email.email && !x.DelFlag);
                string Username = taikhoan.Username;

                string         token   = Common.Common.GetToken(taikhoan.Id);
                TblTokenResset tokenLG = new TblTokenResset
                {
                    Id_TaiKhoan    = taikhoan.Id,
                    TokenReset     = token,
                    ThoiGianHetHan = DateTime.Now.AddHours(12)
                };
                context.ResetPassWords.Add(tokenLG);
                context.SaveChanges();
                token = BaoMat.Base64Encode(token);
                string Subject = "Password Reset Confirmation for " + Username;
                string body    = "<p>There was recently a request to change the password for your account. </p>" +
                                 "<p>If you requested this password change, please reset your password here: </p>" +
                                 "<p> https://truyenda.tk/forgot?token=" + token + "</p>" +
                                 "<p>If you did not make this request, you can ignore this message and your password will remain the same.</p>";
                SendMail.SendGird(email.email, body, Subject);
                var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.GuiEmailThanhCong);
                result.TypeMsgError = errorMsg.Type;
                result.MsgError     = errorMsg.Msg;
                return(result);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Cập nhật quyền cho thành viên
        /// Author       :   HoangNM - 07/05/2019 - create
        /// </summary>
        /// <param name="data">thông tin về nhóm dịch muốn thay đổi</param>
        /// <returns>Trả về các thông tin khi cập nhật nhóm dịch, Excetion nếu có lỗi</returns>
        public ResponseInfo UpadateThanhVienRole(UpdateThanhVien data, int id)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();
            ResponseInfo         response    = new ResponseInfo();

            try
            {
                context.TaiKhoans.Where(x => x.Id == id && !x.DelFlag)
                .Update(x => new TblTaiKhoan
                {
                    Id_PhanQuyen = data.Id_Role
                });
                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>
        /// Cập nhật thông tin phân quyền
        /// Author       :   HoangNM - 16/04/2019 - create
        /// </summary>
        /// <param name="phanQuyen">thông tin về phân quyền muốn thay đổi</param>
        /// <param name="id">là id của quyền muốn cập nhật</param>
        /// <returns>Trả về các thông tin khi cập nhật quyền, Excetion nếu có lỗi</returns>
        public ResponseInfo UpadatePhanQuyen(NewPhanQuyen phanQuyen, int id)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();
            ResponseInfo         response    = new ResponseInfo();

            try
            {
                decimal TongQuyen = 0;
                foreach (int i in phanQuyen.Id_QuyenList)
                {
                    TongQuyen += context.Quyens.FirstOrDefault(x => x.Id == i && !x.DelFlag).BitQuyen;
                }
                context.PhanQuyens.Where(x => x.Id == id && !x.DelFlag)
                .Update(x => new TblPhanQuyen
                {
                    TenVaiTro = phanQuyen.TenVaiTro,
                    TongQuyen = TongQuyen
                });
                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;
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Thêm chương truyện
        /// Author       :   HoangNM - 04/04/2019 - create
        /// </summary>
        /// <param name="data">Dữ liệu của truyện sẽ thêm</param>
        /// <returns>Trả về các thông tin khi thêm chương truyện, Excetion nếu có lỗi</returns>
        public ResponseInfo ThemChuongTruyen(ChuongCuaTruyen chuongTruyen)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();

            try
            {
                ResponseInfo response = new ResponseInfo();

                chuongTruyen.Id = context.Chuongs.Count() == 0 ? 1 : context.Chuongs.Max(x => x.Id) + 1;
                context.Chuongs.Add(new TblChuongTruyen
                {
                    Id        = chuongTruyen.Id,
                    Id_Truyen = chuongTruyen.IdTruyen,
                    TenChuong = chuongTruyen.TenChuong,
                    SoThuTu   = chuongTruyen.SoThuTu,
                    LinkAnh   = chuongTruyen.LinkAnh,
                    LuotXem   = 0,
                    NgayTao   = DateTime.Now
                });
                context.SaveChanges();
                response.ThongTinBoSung1 = chuongTruyen.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;
            }
        }
Esempio n. 18
0
        // Cập nhật thông tin theo dõi truyện

        public ResponseInfo UpadateTheoDoi(int id, UpdateTheoDoi data)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();
            ResponseInfo         response    = new ResponseInfo();

            try
            {
                int idTaiKhoan = Common.Common.GetAccount().Id;
                context.TheoDoiTruyens.Where(x => x.Id == id && !x.DelFlag)
                .Update(x => new TblTheoDoiTruyen
                {
                    Id_ChuongDanhDau = data.IdChuongTheoDoi,
                    Id_NguoiDoc      = idTaiKhoan
                });
                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;
            }
        }
        public ResponseInfo UpdateTacGia(TacGia data, int id)
        {
            ResponseInfo response = new ResponseInfo();
            var          kt       = Convert.ToInt64(new GetPermission().GetQuyen("AUTHOR_UPD")) & Convert.ToInt64(Common.Common.GetTongQuyen());

            if (kt != 0)
            {
                try
                {
                    response = new QuanLyTacGiaModel().UpadateTacGia(data, id);
                }
                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;
                }
            }
            else
            {
                var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.BanKhongDuQuyen);
                response.TypeMsgError = errorMsg.Type;
                response.MsgError     = errorMsg.Msg;
            }

            return(response);
        }
        public ResponseInfo UpadateThanhVienRole(UpdateThanhVien data, int Id_TaiKhoan)
        {
            ResponseInfo response = new ResponseInfo();
            var          kt       = Convert.ToInt64(new GetPermission().GetQuyen("TEAMMEM_PER")) & Convert.ToInt64(Common.Common.GetTongQuyen());

            if (kt != 0)
            {
                try
                {
                    response = new QuanLyThanhVienTrongNhomModel().UpadateThanhVienRole(data, Id_TaiKhoan);
                }
                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;
                }
            }
            else
            {
                var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.BanKhongDuQuyen);
                response.TypeMsgError = errorMsg.Type;
                response.MsgError     = errorMsg.Msg;
            }

            return(response);
        }
Esempio n. 21
0
        public HttpResponseMessage CheckLogin(TaiKhoan account)
        {
            ResponseInfo response = new ResponseInfo();
            var          resp     = Request.CreateResponse(HttpStatusCode.InternalServerError, response);

            try
            {
                if (ModelState.IsValid)
                {
                    response         = new LoginModel().CheckAccount(account);
                    response.IsValid = true;
                    if (response.Code == 200)
                    {
                        resp = Request.CreateResponse(HttpStatusCode.OK, response);
                        var cookie = new CookieHeaderValue("ToKen", response.ThongTinBoSung1);
                        response.ThongTinBoSung1 = null;
                        cookie.Expires           = DateTimeOffset.Now.AddDays(1);
                        cookie.Domain            = "truyenda.tk";
                        //cookie.Domain = Request.RequestUri.Host;
                        cookie.Path = "/";

                        resp.Headers.AddCookies(new CookieHeaderValue[] { cookie });
                    }
                    else
                    {
                        resp = Request.CreateResponse(HttpStatusCode.BadRequest, response);
                        Request.CreateResponse(response);
                    }
                }
                else
                {
                    response.Code = (int)ConstantsEnum.CodeResponse.NotValidate;
                    var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.DuLieuNhapSai);
                    response.TypeMsgError = errorMsg.Type;
                    response.MsgError     = errorMsg.Msg;
                }
            }
            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(resp);
        }
Esempio n. 22
0
        /// <summary>
        /// Cập nhật thông tin chương truyện
        /// Author       :   HoangNM - 14/04/2019 - create
        /// </summary>
        /// <param name="chuong">thông tin về chương truyện muốn thay đổi</param>
        /// <returns>Trả về các thông tin khi cập nhật chương truyện, Excetion nếu có lỗi</returns>
        public ResponseInfo UpadateChuongTruyen(ChuongCuaTruyen chuong, int id)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();
            ResponseInfo         response    = new ResponseInfo();

            try
            {
                var kt = Convert.ToInt64(new GetPermission().GetQuyen("CHAPTER_MAN")) & Convert.ToInt64(Common.Common.GetTongQuyen());
                if (kt != 0)
                {
                    context.Chuongs.Where(x => x.Id == id && !x.DelFlag)
                    .Update(x => new TblChuongTruyen
                    {
                        Id_Truyen = chuong.IdTruyen,
                        TenChuong = chuong.TenChuong,
                        SoThuTu   = chuong.SoThuTu,
                        LinkAnh   = chuong.LinkAnh
                    });
                }
                else
                {
                    context.Chuongs.Where(x => x.Id == id && x.Truyen.Id_Nhom == Common.Common.GetAccount().IdNhom&& !x.DelFlag)
                    .Update(x => new TblChuongTruyen
                    {
                        Id_Truyen = chuong.IdTruyen,
                        TenChuong = chuong.TenChuong,
                        SoThuTu   = chuong.SoThuTu,
                        LinkAnh   = chuong.LinkAnh
                    });
                }

                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;
            }
        }
Esempio n. 23
0
        //Lấy lại mật khẩu
        public ResponseInfo ChangePassword(ChangePass data)
        {
            ResponseInfo result = new ResponseInfo();

            try
            {
                string         Token         = BaoMat.Base64Decode(data.tokenReset);
                TblTokenResset resetPassWord = context.ResetPassWords.FirstOrDefault(x => x.TokenReset == Token && !x.DelFlag);
                if (resetPassWord == null)
                {
                    result.Code = 400;
                    var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.ThayDoiMatKhauThatBai);
                    result.TypeMsgError = errorMsg.Type;
                    result.MsgError     = errorMsg.Msg;
                }
                else if (resetPassWord.ThoiGianHetHan < DateTime.Now)
                {
                    result.Code = 400;
                    var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.TokenResetHetHan);
                    result.TypeMsgError = errorMsg.Type;
                    result.MsgError     = errorMsg.Msg;
                }
                else
                {
                    string Hash_Pass = BaoMat.GetMD5(BaoMat.GetSimpleMD5(data.NewPass), context.TaiKhoans.Where(x => x.Id == resetPassWord.Id_TaiKhoan && !x.DelFlag).FirstOrDefault().salt_Pass);
                    //cập nhật mật khẩu
                    context.TaiKhoans.Where(x => x.Id == resetPassWord.Id_TaiKhoan && !x.DelFlag).Update(y => new TblTaiKhoan
                    {
                        hash_Pass = Hash_Pass
                    });
                    context.ResetPassWords.Where(x => x.TokenReset == Token).Delete();
                    context.ResetPassWords.Where(x => x.ThoiGianHetHan < DateTime.Now).Delete();
                    context.SaveChanges();
                    var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.ThayDoiMatKhauThanhCong);
                    result.TypeMsgError = errorMsg.Type;
                    result.MsgError     = errorMsg.Msg;
                    return(result);
                }
                return(result);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Update thông tin cá nhân
        /// Author       :   HoangNM - 29/03/2019 - create
        /// </summary>
        /// <param name="account">
        /// thông tin mà người dùng muốn thay đổi
        /// </param>
        /// <returns>
        /// Thông báo
        /// </returns>

        public ResponseInfo UpdateAccount(UpdateAccount account)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();
            ResponseInfo         response    = new ResponseInfo();

            try
            {
                string token = HttpContext.Current.Request.Cookies["ToKen"].Value.Replace("%3d", "=");
                token = BaoMat.Base64Decode(token);
                TblToken TblToken = context.Tokens.FirstOrDefault(x => x.TokenTaiKhoan == token);

                if (account.New_Passord != "" && string.Compare(account.New_Passord, account.Confirm_Password) == 0)
                {
                    string Hash_Pass = BaoMat.GetMD5(BaoMat.GetSimpleMD5(account.New_Passord), context.TaiKhoans.Where(x => x.Id == TblToken.TaiKhoan.Id && !x.DelFlag).FirstOrDefault().salt_Pass);
                    //cập nhật mật khẩu
                    context.TaiKhoans.Where(x => x.Id == TblToken.TaiKhoan.Id && !x.DelFlag).Update(y => new TblTaiKhoan
                    {
                        hash_Pass = Hash_Pass
                    });
                }


                context.ThongTinNguoiDungs.Where(x => x.Id == TblToken.TaiKhoan.ThongTinNguoiDung.Id && !x.DelFlag).Update(x => new TblUser
                {
                    Ten      = account.Ten,
                    NgaySinh = account.NgaySinh,
                    GioiTinh = account.GioiTinh
                });
                context.SaveChanges();
                response.IsSuccess = true;
                transaction.Commit();

                var errorMsg = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.CapNhatThongTinThanhCong);
                response.TypeMsgError = errorMsg.Type;
                response.MsgError     = errorMsg.Msg;
            }
            catch (Exception e)
            {
                response.IsSuccess = false;
                transaction.Rollback();
                throw e;
            }

            return(response);
        }
Esempio n. 25
0
        /// <summary>
        /// Cập nhật thông tin truyện
        /// Author       :   HoangNM - 01/04/2019 - create
        /// </summary>
        /// <param name="truyen">thông tin về truyện muốn thay đổi</param>
        /// <returns>Trả về các thông tin khi cập nhật truyện, Excetion nếu có lỗi</returns>
        public ResponseInfo UpadateTruyen(NewComic truyen, int id)
        {
            DbContextTransaction transaction = context.Database.BeginTransaction();
            ResponseInfo         response    = new ResponseInfo();

            try
            {
                var kt      = Convert.ToInt64(new GetPermission().GetQuyen("STORY_MAN")) & Convert.ToInt64(Common.Common.GetTongQuyen());
                int Id_nhom = Common.Common.GetAccount().IdNhom;
                truyen.Id_NhomDich = truyen.Id_NhomDich == 0 ? Id_nhom : truyen.Id_NhomDich;
                if (kt != 0)
                {
                    XuLyUpDateTruyen(truyen, id);
                }
                else
                {
                    TblTruyen tblTruyen = context.Truyens.FirstOrDefault(x => x.Id == id && x.Id_Nhom == Id_nhom && !x.DelFlag);
                    if (tblTruyen != null)
                    {
                        XuLyUpDateTruyen(truyen, id);
                    }
                    else
                    {
                        var errorMsg1 = new GetErrorMsg().GetMsg((int)MessageEnum.MsgNO.CapNhatThongTinThanhCong);
                        response.TypeMsgError = errorMsg1.Type;
                        response.MsgError     = errorMsg1.Msg;
                        return(response);
                    }
                }

                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;
            }
        }
 public ResponseInfo Get(int id)
 {
     ResponseInfo response = new ResponseInfo();
     try
     {
         response.Data = new QuanLyChuongTruyenModel().LoadChuongTruyen(id);
         response.IsSuccess = true;
     }
     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;
 }
        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);
        }
        public ResponseInfo UpdateAccount(UpdateAccount account)
        {
            ResponseInfo response = new ResponseInfo();

            try
            {
                response           = new InformationModel().UpdateAccount(account);
                response.IsSuccess = true;
            }
            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);
        }
Esempio n. 29
0
        public ResponseInfo DanhSachPhanQuyen()
        {
            ResponseInfo response = new ResponseInfo();

            try
            {
                response.IsSuccess = true;
                response.Data      = new QuanLyPhanQuyenModel().GetDanhSachPhanQuyen();
            }
            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);
        }
        public ResponseInfo DanhSachTruyenVoiTacGia(int Id_TacGia)
        {
            ResponseInfo response = new ResponseInfo();

            try
            {
                response.Data      = new QuanLyTacGiaModel().GetListTruyenWithAuthor(Id_TacGia);
                response.IsSuccess = true;
            }
            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);
        }