Ejemplo n.º 1
0
        public void ShowUserGroupView(UserGroupDTO userGroup, ActionType action)
        {
            var view = ServiceLocator.Current.GetInstance <IUserGroupView>();

            ((UserGroupVM)view.ViewModel).Load(userGroup, action);
            viewManager.ShowInDialog(view);
        }
Ejemplo n.º 2
0
 private string GetSelect(UserGroupDTO user)
 {
     return(@"<select name=""Status"">" + GetOption(UserGroupStatus.request, 0, "Запрос", user.Status)
            + GetOption(UserGroupStatus.member, 1, "Участник", user.Status)
            + GetOption(UserGroupStatus.owner, 2, "Модератор", user.Status)
            + @"<option value=""4"">Удалить</option></select>");
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Update record by using the table's primary key.
        /// </summary>
        /// <param name="database"></param>
        /// <param name="data">Data which to update.</param>
        /// <param name="oldGROUP_CD">Old Key #1</param>
        /// <returns></returns>
        public int UpdateWithPK(Database database, UserGroupDTO data, NZString oldGROUP_CD)
        {
            Database db = UseDatabase(database);

            StringBuilder sb = new StringBuilder();

            #region SQL Statement
            sb.AppendLine(" UPDATE " + data.TableName);
            sb.AppendLine(" SET ");
            sb.AppendLine("  " + UserGroupDTO.eColumns.GROUP_CD + "=:GROUP_CD");
            sb.AppendLine("  ," + UserGroupDTO.eColumns.GROUP_NAME + "=:GROUP_NAME");
            sb.AppendLine("  ," + UserGroupDTO.eColumns.UPD_BY + "=:UPD_BY");
            sb.AppendLine("  ," + UserGroupDTO.eColumns.UPD_DATE + "=GETDATE()");
            sb.AppendLine("  ," + UserGroupDTO.eColumns.UPD_MACHINE + "=:UPD_MACHINE");
            sb.AppendLine(" WHERE ");
            sb.AppendLine("  " + UserGroupDTO.eColumns.GROUP_CD + "=:oldGROUP_CD");
            #endregion

            DataRequest req = new DataRequest(sb.ToString());
            #region Parameters
            req.Parameters.Add("GROUP_CD", DataType.NVarChar, data.GROUP_CD.Value);
            req.Parameters.Add("GROUP_NAME", DataType.NVarChar, data.GROUP_NAME.Value);
            req.Parameters.Add("UPD_BY", DataType.NVarChar, data.UPD_BY.Value);
            req.Parameters.Add("UPD_MACHINE", DataType.NVarChar, data.UPD_MACHINE.Value);
            req.Parameters.Add("oldGROUP_CD", DataType.NVarChar, oldGROUP_CD.Value);
            #endregion

            return(db.ExecuteNonQuery(req));
        }
Ejemplo n.º 4
0
        public IActionResult Update(UserGroupDTO userGroupDTO, int Id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessage()));
            }
            else
            {
                IDataResult <UserGroup> result = _iUserGroupService.GetById(Id);
                if (result == null)
                {
                    return(BadRequest(result.Message));
                }
                else
                {
                    _iMapper = UserGroupMapping.GetMapper().CreateMapper();
                    UserGroup userGroup = _iMapper.Map <UserGroupDTO, UserGroup>(userGroupDTO);

                    IResult updateResult = _iUserGroupService.Update(userGroup);

                    if (updateResult.Success)
                    {
                        return(Ok(updateResult.Message));
                    }
                    return(BadRequest(updateResult.Message));
                }
            }
        }
Ejemplo n.º 5
0
 public void CheckDataBeforeSave(UserGroupDTO data)
 {
     if (Util.IsNullOrEmpty(data.GroupID))
     {
         throw new ApplicationException("GroupName cannot be empty. Please input data of GroupName.");//GroupName cannot be empty. Please input data of GroupName.
     }
 }
Ejemplo n.º 6
0
        public async Task <IActionResult> UpdateAsync(UserGroupDTO userGroupDTO, int Id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessage()));
            }
            else
            {
                IDataResult <UserGroup> dataResult = await _iUserGroupService.FindByIdAsync(Id);

                if (dataResult.Data == null)
                {
                    return(BadRequest(dataResult.Message));
                }
                _iMapper = UserGroupMapping.GetMapper().CreateMapper();

                UserGroup userGroup = _iMapper.Map <UserGroupDTO, UserGroup>(userGroupDTO);

                IResult result = await _iUserGroupService.UpdateAsync(userGroup);

                if (result.Success)
                {
                    return(Ok(result.Message));
                }
                return(BadRequest(result.Message));
            }
        }
Ejemplo n.º 7
0
        private UserGroupDTO ToDTO(UserGroup userGroup)
        {
            UserGroupDTO dto = new UserGroupDTO();

            dto.Name = userGroup.Name;
            dto.Id   = userGroup.Id;
            return(dto);
        }
Ejemplo n.º 8
0
        private static UserGroupDTO ToUserGroupDTO(UserGroup group)
        {
            UserGroupDTO dto = new UserGroupDTO();

            dto.Id   = group.Id;
            dto.Name = group.Name;
            return(dto);
        }
Ejemplo n.º 9
0
 public IActionResult AddStudentToGroup(UserGroupDTO newStudentGroupConnection)
 {
     if (newStudentGroupConnection.StudentId > 0 && newStudentGroupConnection.GroupId > 0)
     {
         _userService.AddUserToGroup(newStudentGroupConnection.StudentId, newStudentGroupConnection.GroupId);
         return(Ok());
     }
     return(NotFound());
 }
Ejemplo n.º 10
0
 public UserGroupVM(IUserServiceWrapper userService,
                    IPMSController appController,
                    IBasicInfoAppLocalizedResources basicInfoAppLocalizedResources)
 {
     this.userService               = userService;
     this.appController             = appController;
     BasicInfoAppLocalizedResources = basicInfoAppLocalizedResources;
     UserGroup   = new UserGroupDTO();
     DisplayName = BasicInfoAppLocalizedResources.UserGroupViewTitle;
 }
Ejemplo n.º 11
0
        public void Update(UserGroupDTO data)
        {
            DataRequest req = new DataRequest("sp_ADM030_UpdateUserGroups", CommandType.StoredProcedure);

            req.Parameters.Add("@GroupName", SqlDbType.VarChar, data.GroupName);
            req.Parameters.Add("@Description", SqlDbType.VarChar, data.Description);
            req.Parameters.Add("@UpdateUser", SqlDbType.VarChar, data.UpdateUser);
            req.Parameters.Add("@GroupID", SqlDbType.Decimal, data.GroupID);
            m_db.ExecuteNonQuery(req);
        }
Ejemplo n.º 12
0
        public int AddNewGroup(UserGroupDTO dto)
        {
            UserGroupValidator valUserGroup = new UserGroupValidator();

            if (valUserGroup.ValidateBeforeAdd(dto))
            {
                IUserGroupDAO dao = DAOFactory.CreateUserGroupDAO(CommonLib.Common.CurrentDatabase);
                return(dao.AddNew(null, dto));
            }
            return(0);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Check exist before manipulate data. If found record will update data. Otherwise insert new data.
        /// </summary>
        /// <param name="database"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public int AddNewOrUpdate(Database database, UserGroupDTO data)
        {
            Database db = UseDatabase(database);

            if (Exist(database, data.GROUP_CD))
            {
                return(UpdateWithoutPK(db, data));
            }

            return(AddNew(db, data));
        }
Ejemplo n.º 14
0
 public HtmlString Invoke(UserGroupDTO DTO, int GroupId, bool inGroup)
 {
     if (inGroup)
     {
         return(new HtmlString(GetInGroup(DTO, GroupId)));
     }
     else
     {
         return(new HtmlString(GetNotInGroup(DTO, GroupId)));
     }
 }
 public void DeleteUserGroup(UserGroupDTO course)
 {
     using var connection = new SQLiteConnection(DatabaseAgent.ConnectionString);
     {
         connection.Open();
         using var command = new SQLiteCommand(SqlStatements.DeleteUserGroup, connection);
         {
             command.Parameters.AddWithValue("$Id", course.Id);
             command.Prepare();
             command.ExecuteNonQuery();
         }
     }
 }
 public void InsertUserGroup(UserGroupDTO course)
 {
     using var connection = new SQLiteConnection(DatabaseAgent.ConnectionString);
     {
         connection.Open();
         using var command = new SQLiteCommand(SqlStatements.InsertUserGroup, connection);
         {
             command.Parameters.AddWithValue("$Name", course.Name);
             command.Prepare();
             command.ExecuteNonQuery();
             course.Id = GetLastInsertRowId(connection);
         }
     }
 }
Ejemplo n.º 17
0
        public bool UpdateGroupDescController(CreateGroupDomain groupDm)
        {
            UserGroupBIZ UserGroupBIZ = new UserGroupBIZ();
            UserGroupDTO userGroupDTO = new UserGroupDTO();

            userGroupDTO.UPD_BY         = CommonLib.Common.CurrentUserInfomation.Username;
            userGroupDTO.UPD_DATE.Value = DateTime.Now;
            userGroupDTO.UPD_MACHINE    = CommonLib.Common.CurrentUserInfomation.UserCD;
            userGroupDTO.GROUP_CD       = groupDm.GroupCD;
            userGroupDTO.GROUP_NAME     = groupDm.GroupDesc;


            UserGroupBIZ.UpdateGroupDesc(userGroupDTO);
            return(true);
        }
Ejemplo n.º 18
0
        public async Task <bool> InsertOneToManyAsync(UserGroupDTO dt)
        {
            bool result = false;

            try
            {
                var GROUPID = await _connection.DB.ExecuteScalarAsync <int>(@"INSERT USER_GROUPS(NAME) values(@NAME) select SCOPE_IDENTITY()", dt);

                foreach (var user in dt.USERS)
                {
                    user.GROUPiD = GROUPID;
                    await _connection.DB.ExecuteAsync(@"INSERT USERS(USERTYPEID,GROUPID,FIRST_NAME,LAST_NAME,EMAIL,PASSWORD,PHONE) values(@USERTYPEiD,@GROUPiD,@FiRST_NAME,@LAST_NAME,@EMAiL,@PASSWORD,@PHONE); select SCOPE_IDENTITY();", user);
                }
                result = true;
            }
            catch { }
            return(result);
        }
Ejemplo n.º 19
0
        public async Task <bool> DeleteOneToManyAsync(UserGroupDTO dt)
        {
            bool result = false;

            try
            {
                await _connection.DB.ExecuteAsync(@"DELETE FROM USER_GROUPS WHERE ID = @GROUPiD", dt);

                foreach (var user in dt.USERS)
                {
                    user.GROUPiD = dt.GROUPiD;
                    await _connection.DB.ExecuteAsync(@"DELETE FROM USERS WHERE GROUPID = @GROUPiD AND ID = @UseriD", user);
                }
                result = true;
            }
            catch { }
            return(result);
        }
Ejemplo n.º 20
0
        public async Task <bool> UpdateOneToManyAsync(UserGroupDTO dt)
        {
            bool result = false;

            try
            {
                await _connection.DB.ExecuteAsync(@"UPDATE USER_GROUPS SET NAME= @NAME WHERE ID = @GROUPiD", dt);

                foreach (var user in dt.USERS)
                {
                    user.GROUPiD = dt.GROUPiD;
                    await _connection.DB.ExecuteAsync(@"UPDATE USERS SET FIRST_NAME= @FiRST_NAME WHERE GROUPID = @GROUPiD AND ID = @UseriD", user);
                }
                result = true;
            }
            catch { }
            return(result);
        }
Ejemplo n.º 21
0
        public List <UserGroupDTO> GetUserGroup(string groupID, string vaiTro)
        {
            string sql = string.Format("Select UserName, Description, active from  SYS_USER where [GR_ID] = N'{0}'", groupID);

            DataTable           data     = ConnectionDB.getData(sql);
            List <UserGroupDTO> listUser = new List <UserGroupDTO>();

            for (int i = 0; i < data.Rows.Count; i++)
            {
                UserGroupDTO user = new UserGroupDTO();
                user.userName = data.Rows[i]["UserName"].ToString();
                user.dienGia  = data.Rows[i]["Description"].ToString();
                user.vaiTro   = vaiTro;
                user.kichHoat = bool.Parse(data.Rows[i]["Active"].ToString());
                user.groupID  = groupID;
                listUser.Add(user);
            }
            return(listUser);
        }
Ejemplo n.º 22
0
        public async Task <IActionResult> InsertOneToManyAsync()
        {
            var dt = new UserGroupDTO
            {
                NAME  = "One To Many 2",
                USERS = new List <UserDTO>
                {
                    new UserDTO {
                        FiRST_NAME = "Eyüp One To Many 1", LAST_NAME = "Ensar", EMAiL = "*****@*****.**", PASSWORD = "******", PHONE = "05550000000", GROUPiD = 1, USERTYPEiD = 1
                    },
                    new UserDTO {
                        FiRST_NAME = "Eyüp One To Many 2", LAST_NAME = "Ensar", EMAiL = "*****@*****.**", PASSWORD = "******", PHONE = "05550000000", GROUPiD = 1, USERTYPEiD = 1
                    }
                }
            };
            var rs = await _userService.InsertOneToManyAsync(dt);

            return(View());
        }
Ejemplo n.º 23
0
        public IActionResult Add(UserGroupDTO UserGroupDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessage()));
            }
            else
            {
                _iMapper = UserGroupMapping.GetMapper().CreateMapper();
                UserGroup userGroup = _iMapper.Map <UserGroupDTO, UserGroup>(UserGroupDTO);

                IResult result = _iUserGroupService.Add(userGroup);

                if (result.Success)
                {
                    return(Ok(result.Message));
                }
                return(BadRequest(result.Message));
            }
        }
Ejemplo n.º 24
0
        public int AddNew(UserGroupDTO data)
        {
            DataRequest req = new DataRequest("sp_ADM030_AddNewUserGroups", CommandType.StoredProcedure);

            req.Parameters.Add("@GroupName", SqlDbType.VarChar, data.GroupName);
            req.Parameters.Add("@Description", SqlDbType.VarChar, data.Description);
            req.Parameters.Add("@CreateUser", SqlDbType.VarChar, data.CreateUser);
            req.Parameters.Add("@UpdateUser", SqlDbType.VarChar, data.UpdateUser);

            DataRequest.Parameter param = new DataRequest.Parameter();
            param.Name          = "@GroupID";
            param.ParameterType = SqlDbType.Int;
            param.Direction     = ParameterDirection.Output;
            param.Size          = 40;
            req.Parameters.Add(param);

            m_db.ExecuteNonQuery(req);

            return(Util.ConvertTextToInteger(param.Value.ToString()));
        }
Ejemplo n.º 25
0
        public async Task <IActionResult> AddAsync(UserGroupDTO userGroupDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessage()));
            }
            else
            {
                _iMapper = UserGroupMapping.GetMapper().CreateMapper();

                UserGroup userGroup = _iMapper.Map <UserGroupDTO, UserGroup>(userGroupDTO);

                IResult result = await _iUserGroupService.AddAsync(userGroup);

                if (result.Success)
                {
                    return(Ok(result.Message));
                }
                return(BadRequest($"{result.Message} \n Try Again later can be either server error or user error "));
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Insert new record into database.
        /// </summary>
        /// <param name="database"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public int AddNew(Database database, UserGroupDTO data)
        {
            Database db = UseDatabase(database);

            StringBuilder sb = new StringBuilder();

            #region SQL Statement
            sb.AppendLine(" INSERT INTO " + data.TableName + "(");
            sb.AppendLine("  " + UserGroupDTO.eColumns.GROUP_CD);
            sb.AppendLine("  ," + UserGroupDTO.eColumns.GROUP_NAME);
            sb.AppendLine("  ," + UserGroupDTO.eColumns.CRT_BY);
            sb.AppendLine("  ," + UserGroupDTO.eColumns.CRT_DATE);
            sb.AppendLine("  ," + UserGroupDTO.eColumns.CRT_MACHINE);
            sb.AppendLine("  ," + UserGroupDTO.eColumns.UPD_BY);
            sb.AppendLine("  ," + UserGroupDTO.eColumns.UPD_DATE);
            sb.AppendLine("  ," + UserGroupDTO.eColumns.UPD_MACHINE);
            sb.AppendLine(") VALUES(");
            sb.AppendLine("   :GROUP_CD");
            sb.AppendLine("   ,:GROUP_NAME");
            sb.AppendLine("   ,:CRT_BY");
            sb.AppendLine("   ,GETDATE()");
            sb.AppendLine("   ,:CRT_MACHINE");
            sb.AppendLine("   ,:UPD_BY");
            sb.AppendLine("   ,GETDATE()");
            sb.AppendLine("   ,:UPD_MACHINE");
            sb.AppendLine(" )");
            #endregion

            DataRequest req = new DataRequest(sb.ToString());
            #region Parameters
            req.Parameters.Add("GROUP_CD", DataType.NVarChar, data.GROUP_CD.Value);
            req.Parameters.Add("GROUP_NAME", DataType.NVarChar, data.GROUP_NAME.Value);
            req.Parameters.Add("CRT_BY", DataType.NVarChar, data.CRT_BY.Value);
            req.Parameters.Add("CRT_MACHINE", DataType.NVarChar, data.CRT_MACHINE.Value);
            req.Parameters.Add("UPD_BY", DataType.NVarChar, data.UPD_BY.Value);
            req.Parameters.Add("UPD_MACHINE", DataType.NVarChar, data.UPD_MACHINE.Value);
            #endregion

            return(db.ExecuteNonQuery(req));
        }
Ejemplo n.º 27
0
        public bool ValidateBeforeAdd(UserGroupDTO usergroupDTO)
        {
            ValidateException validateException = new ValidateException();
            ErrorItem         errorItem         = null;

            errorItem = CheckExistGroupCD(usergroupDTO.GROUP_CD);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
                throw validateException;
            }

            errorItem = CheckUserName(usergroupDTO.GROUP_NAME);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
                throw validateException;
            }


            return(true);
        }
Ejemplo n.º 28
0
        public int UpdateGroupDesc(Database database, UserGroupDTO dto)
        {
            Database db = UseDatabase(database);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(" UPDATE TZ_USER_GROUP_MS ");
            sb.AppendLine("    SET GROUP_NAME  = :GROUP_NAME, ");
            sb.AppendLine("        UPD_BY      = :UPD_BY, ");
            sb.AppendLine("        UPD_DATE    = :UPD_DATE, ");
            sb.AppendLine("        UPD_MACHINE = :UPD_MACHINE ");
            sb.AppendLine("  WHERE GROUP_CD = :GROUP_CD ");

            DataRequest req = new DataRequest(sb.ToString());

            req.Parameters.Add("GROUP_NAME", DataType.VarChar, dto.GROUP_NAME.StrongValue);
            req.Parameters.Add("UPD_BY", DataType.VarChar, dto.UPD_BY.StrongValue);
            req.Parameters.Add("UPD_DATE", DataType.DateTime, dto.UPD_DATE.StrongValue);
            req.Parameters.Add("UPD_MACHINE", DataType.VarChar, dto.UPD_MACHINE.StrongValue);
            req.Parameters.Add("GROUP_CD", DataType.VarChar, dto.GROUP_CD.StrongValue);
            return(db.ExecuteNonQuery(req));
        }
Ejemplo n.º 29
0
        public UserGroupDTO UpdateUserGroup(UserGroupDTO userGroup)
        {
            Group u = securityService.UpdateUserGroup(new PartyId(userGroup.PartyName), userGroup.Description, userGroup.CustomActions);

            return(userGroupDTOMapper.MapToModel(u));
        }
Ejemplo n.º 30
0
 public UserGroup Map(UserGroupDTO dto)
 {
     if (dto == null) return null;
     var userGroup = Mapper.Map<UserGroupDTO, UserGroup>(dto);
     return userGroup;
 }
Ejemplo n.º 31
0
        public int UpdateGroupDesc(UserGroupDTO dto)
        {
            IUserGroupDAO dao = DAOFactory.CreateUserGroupDAO(CommonLib.Common.CurrentDatabase);

            return(dao.UpdateGroupDesc(null, dto));
        }
 public HttpResponseMessage SaveGroup(UserGroupDTO userGroup)
 {
     return SafeAction(() =>
        {
        IDelightServices service = new DelightServices();
        int id = service.SaveUserGroup(userGroup);
        if (id <= 0)
        {
            return Request.CreateResponse(HttpStatusCode.NoContent);
        }
        var response = Request.CreateResponse<int>(HttpStatusCode.OK, id);
        return response;
        }, userGroup);
 }
 public Int32 SaveUserGroup(UserGroupDTO userGroup)
 {
     using (DelightServiceClient service = new DelightServiceClient())
     {
         return service.SaveUserGroup(userGroup);
     }
 }