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)); } } }
public ActionResult Index() { var userModel = _userService.GetAll(); var userViewModel = Mapper.Map <IEnumerable <User>, IEnumerable <UserViewModel> >(userModel); foreach (var user in userViewModel) { user.GroupDisplayName = _userGroupService.GetById(user.GroupID).DisplayName; } return(View(userViewModel)); }
public IActionResult GetById(int id) { try { return(Ok(_userGroupService.GetById(id))); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }
public ActionResult Edit(string id) { try { return(View(Mapper.Map <UserGroupViewModel>(_userGroupService.GetById(id)))); } catch (Exception ex) { return(JavaScript($"ShowResult('{ex.Message}','failure')")); } }
public async Task <ActionResult> GetUserGroup(int groupId) { if (!IsAvailableOperation()) { return(BadRequest()); } var groupDto = await _userGroupService.GetById(groupId, UserId); return(Ok(groupDto)); }
public IActionResult GetGroup(string groupId) { var group = userGroupService.GetById <UserGroupViewModel>(groupId, new string[] { "Message.User" }); group.Message = group.Message.OrderBy(c => c.Date).ToList(); if (group != null) { return(Ok(group)); } return(BadRequest()); }
public ActionResult Index(string userId, string password, string returnUrl) { try { string workStationIp = GetLocalIpAddress(System.Web.HttpContext.Current); var userInfo = _userService.Login(userId, password); if (!string.IsNullOrEmpty(userInfo?.Id)) { var userGroup = _userGroupService.GetById(userInfo.UserGroupId); var company = new Company(); var branch = new Branch(); if (!string.IsNullOrEmpty(userGroup?.Id)) { company = _userService.GetCompanyInfo(userGroup.CompanyId); branch = _userService.GetBranchInfo(userGroup.BranchId); } string[] roles = _userService.GetUserRoles(userId); string basicTicket = LoginIdentity.CreateBasicTicket( userInfo.UserId, company?.Id, company?.Name, branch?.Id, branch?.Name, workStationIp, userInfo.SysAdmin, true); string roleTicket = LoginIdentity.CreateRoleTicket(roles); FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, FormsAuthentication.FormsCookieName, DateTime.Now, DateTime.Now.AddMinutes(720), true, basicTicket); string encTicket = FormsAuthentication.Encrypt(authTicket); HttpContext.Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket)); HttpContext.Application["BasicTicket" + userId] = basicTicket; HttpContext.Application["RoleTicket" + userId] = roleTicket; if (userInfo.SysAdmin) { return(RedirectToAction("Index", "Home", new { area = "APanel" })); } return(RedirectToAction("Index", "Home", new { area = "" })); } ViewBag.Message = "User Id and password does not match or you are not a valid user..."; return(View()); } catch (Exception ex) { ViewBag.Message = ex.Message; return(View()); } }
public ActionResult Edit(string id) { var mdoel = _userGroupService.GetById(id); return(View(mdoel)); }