public dynamic Xoa_Quyen_Sudung_Chucnang(RoleUpdateRequestModel roleUpdateRequest)
        {
            try
            {
                List <QuyenSudungChucnangModel> list = (from qsdcn in dataContext.QuyenSudungChucnang.Where(c => c.quyen_id == roleUpdateRequest.quyen_id) select qsdcn).ToList();
                dataContext.QuyenSudungChucnang.RemoveRange(list);
                dataContext.SaveChanges();
                dataRespond.success = true;
                dataRespond.message = "Successfully";
            }
            catch (Exception ex)
            {
                dataRespond.success = false;
                dataRespond.message = ex.ToString();
            }

            return(dataRespond);
        }
Ejemplo n.º 2
0
        public ActionResult <CommonResponeModel> Update(RoleUpdateRequestModel model)
        {
            var databaseObject = model.MapTo <UserRole>();

            databaseObject.InitBeforeSave(RequestUsername, InitType.Create);
            int result = roleRepository.Update(databaseObject);

            if (result > 0)
            {
                Result = new SuccessResult(ActionType.Edit, AppGlobal.EditSuccess);
            }
            else
            {
                Result = new ErrorResult(ActionType.Edit, AppGlobal.EditError);
            }

            return(GetCommonRespone());
        }
        public dynamic Them_Quyen_Sudung_Chucnang(RoleUpdateRequestModel roleUpdateRequest)
        {
            Xoa_Quyen_Sudung_Chucnang(roleUpdateRequest);
            int quyen_id = roleUpdateRequest.quyen_id;
            List <ChucnangModel>            ds_chucnang = roleUpdateRequest.ds_chucnang;
            List <QuyenSudungChucnangModel> ds_quyen    = new List <QuyenSudungChucnangModel>();

            try
            {
                foreach (ChucnangModel item in ds_chucnang)
                {
                    QuyenSudungChucnangModel quyen = new QuyenSudungChucnangModel(quyen_id, item.chucnang_id);
                    insert(quyen);
                }
                dataRespond.success = true;
                dataRespond.message = "Successfully";
            }
            catch (Exception ex)
            {
                dataRespond.success = false;
                dataRespond.message = ex.ToString();
            }
            return(dataRespond);
        }
Ejemplo n.º 4
0
 public dynamic Them_Quyen_Sudung_Chucnang([FromBody] RoleUpdateRequestModel roleUpdateRequest)
 {
     return(quyensudungchucnang.Them_Quyen_Sudung_Chucnang(roleUpdateRequest));
 }