Example #1
0
        public List <Sec_Role> ToList(string filter, string Value = null)
        {
            DataTable       dt       = rd.GetRoles(filter, Value);
            List <Sec_Role> lstRoles = new List <Sec_Role>();

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Sec_Role Role = new Sec_Role();
                    Role.RoleId      = int.Parse(dt.Rows[i]["RoleId"].ToString());
                    Role.Name        = dt.Rows[i]["Name"].ToString();
                    Role.Description = dt.Rows[i]["Description"].ToString();
                    Role.DefaultUrl  = dt.Rows[i]["DefaultUrl"].ToString();
                    if (!string.IsNullOrEmpty(dt.Rows[i]["ModifyDate"].ToString()))
                    {
                        Role.Update_at = DateTime.Parse(dt.Rows[i]["ModifyDate"].ToString());
                    }
                    Role.IsActive = bool.Parse(dt.Rows[i]["IsActive"].ToString());
                    lstRoles.Add(Role);
                }
            }

            return(lstRoles);
        }
Example #2
0
        public SystemMessage SaveSecRole(int roleId, int idTable, Sec_Role secRole)
        {
            SystemMessage systemMessage = new SystemMessage();

            try
            {
                //UnitOfWork.ConnectionString = ERP.Framework.Common.Utils.GetSetting<string>("NovaonADConnection");
                var param1 = new DynamicParameters();
                param1.Add("@Name ", secRole.Name);
                param1.Add("@NameEN ", secRole.NameEN);
                param1.Add("@RoleID", secRole.RoleID, DbType.Int32, ParameterDirection.InputOutput);

                UnitOfWork.ProcedureExecute("SecRole_Save", param1);
                systemMessage.IsSuccess = true;
                systemMessage.Message   = "Cập nhật thành công";
                return(systemMessage);
            }
            catch (Exception e)
            {
                systemMessage.IsSuccess = false;
                systemMessage.Message   = e.ToString();
                return(systemMessage);
            }
            finally
            {
                //UnitOfWork.ConnectionString = null;
            }
        }
Example #3
0
 public Sec_RoleModel(Sec_Role entity, bool encodeHtml = false)
 {
     if (entity != null)
     {
         var configMapper = new MapperConfiguration(cfg =>
         {
             cfg.CreateMap <Sec_Role, Sec_RoleModel>();
         });
         configMapper.CreateMapper().Map(entity, this);
     }
 }
Example #4
0
        public Sec_Role GetEntity()
        {
            var configMapper = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Sec_RoleModel, Sec_Role>();
            });

            Sec_Role entity = configMapper.CreateMapper().Map <Sec_RoleModel, Sec_Role>(this);

            return(entity);
        }
Example #5
0
        public Sec_Role ToSingle(string filter, string Value = null)
        {
            DataTable dt   = rd.GetRoles(filter, Value);
            Sec_Role  Role = new Sec_Role();

            if (dt != null && dt.Rows.Count > 0)
            {
                Role.Name        = dt.Rows[0]["Name"].ToString();
                Role.Description = dt.Rows[0]["Description"].ToString();
                Role.RoleId      = int.Parse(dt.Rows[0]["RoleId"].ToString());
                Role.DefaultUrl  = dt.Rows[0]["DefaultUrl"].ToString();
            }

            return(Role);
        }
Example #6
0
 public bool UpdateActiveStatus(int Id, bool status)
 {
     try
     {
         Sec_RoleBL rbl = new Sec_RoleBL();
         Sec_Role   r   = new Sec_Role();
         r.RoleId   = Id;
         r.IsActive = status;
         rbl.Manage("UpdateStatus", r);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Example #7
0
        public ActionResult Delete(int Id)
        {
            try
            {
                Sec_RoleBL rbl = new Sec_RoleBL();
                Sec_Role   r   = new Sec_Role();
                r.RoleId = Id;
                rbl.Manage("Delete", r);
            }
            catch (Exception ex)
            {
                TempData["msg_error"] = ex.Message;
            }

            return(RedirectToAction("All"));
        }
Example #8
0
        public ActionResult _SaveSecRole(Sec_Role secRole)
        {
            var db = new Sec_RoleDAL();

            var result = db.SaveSecRole(1, 1, secRole);

            if (result.IsSuccess == true && secRole.RoleID == 0)
            {
                result.Message = AppRes.MSG_INSERT_SUCCESSFUL;
            }
            else if (result.IsSuccess == true && secRole.RoleID != 0)
            {
                result.Message = AppRes.MS_Update_success;
            }
            return(Content(JsonConvert.SerializeObject(new
            {
                result
            })));
        }
Example #9
0
        public ActionResult New(Sec_Role r)
        {
            try
            {
                Sec_RoleBL rb     = new Sec_RoleBL();
                Int64      RoleId = 0;
                if (r.RoleId > 0)
                {
                    RoleId = rb.Manage("Update", r);
                }
                else
                {
                    RoleId = rb.Manage("Insert", r);
                }

                return(RedirectToAction("All"));
            }
            catch (Exception ex)
            {
                TempData["msg_error"] = ex.Message;
                return(View());
            }
        }
Example #10
0
 public int Manage(string filter, Sec_Role r)
 {
     return(rd.Manage(filter, r.RoleId, r.Name, r.Description, r.IsActive, r.DefaultUrl));
 }