Exemplo n.º 1
0
        /// <summary>
        ///  Remove User
        /// </summary>
        /// <param name="inputModel"></param>
        /// <returns></returns>
        public bool Remove(RemoveUserInputModel inputModel)
        {
            UtUsers row = CheckUser(inputModel);

            if (row != null)
            {
                _context.Remove(row);
                _context.SaveChanges();
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> RemoveDonor(RemoveUserInputModel inputModel)
        {
            try
            {
                string donorName = await this.usersService.RemoveUserAsync(inputModel.Email);

                this.TempData["Msg"] = string.Format(RemoveSuccessMessage, GlobalConstants.DonorRoleName, donorName);
            }
            catch
            {
                this.TempData["Msg"] = string.Format(RemoveErrorMessage, GlobalConstants.DonorRoleName, inputModel.Email);
            }

            return(this.RedirectToAction(nameof(this.Index)));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> RemoveFreelancer(RemoveUserInputModel inputModel)
        {
            try
            {
                string freelancerName = await this.usersService.RemoveAdminAsync(inputModel.Email, GlobalConstants.FreelancerRoleName);

                this.TempData["Success"] = string.Format(RemoveSuccessMessage, GlobalConstants.FreelancerRoleName, freelancerName);
            }
            catch
            {
                this.TempData["Error"] = string.Format(RemoveSuccessMessage, GlobalConstants.FreelancerRoleName, inputModel.Email);
            }

            return(this.RedirectToAction(nameof(this.Index)));
        }
Exemplo n.º 4
0
        public ActionResult <ApiResultModel <int> > Remove([FromForm] RemoveUserInputModel inputModel)
        {
            if (!this.TryValidateModel(inputModel))
            {
                return(Ok(new ApiResultModel <int>(200, 10)));
            }

            bool row    = _userRepository.Remove(inputModel);
            int  status = 0;

            if (row == true)
            {
                status = 1;
            }
            return(Ok(new ApiResultModel <int>(200, status)));
        }
Exemplo n.º 5
0
 private UtUsers CheckUser(RemoveUserInputModel model) => _context.UtUsers.FirstOrDefault(x => x.Username == model.UserName && x.UserGroupId == model.GroupId);