public IActionResult Post([FromBody] AdminUserView userView) { IActionResult response = null; UserModels userModels = new UserModels(); User user = null; var mess = string.Empty; string rt = string.Empty; user = new User { Username = userView.Username, Online = userView.Online, Role = userView.Role, Password = MD5Extend.EncodePassword(userView.Password), Ip = userView.Ip, LastLogin = null }; rt = userModels.AddUser(user, userView); if (rt.Length > 0) { response = Json(new { code = Constant.Success, message = Constant.MessageCreateCompleted }); } else { response = Json(new { code = Constant.Fail, message = Constant.MessageCreateUncompleted }); } return(response); }
public async Task <IActionResult> Show(string uid) { User viewuser; var user = await this._users.GetAsync(uid); if (user == null) { return(this.NotFound()); } viewuser = new AdminUserView { Email = user.Email, FirstName = user.FirstName, LastName = user.LastName, PhoneNumber = user.PhoneNumber, Id = user.Id, RegisteredAt = user.RegisteredAt.ToUniversalTime(), Roles = await this._users.GetRolesAsync(user).AwaitBackground(), BillingLockout = user.BillingLockout, UnconfirmedPhoneNumber = user.UnconfirmedPhoneNumber, EmailConfirmed = user.EmailConfirmed, PasswordLockout = user.LockoutEnd?.UtcDateTime, PasswordLockoutEnabled = user.LockoutEnabled }; return(new ObjectResult(viewuser)); }
public HttpResponseMessage ResetPassword(Guid id, [FromBody] string password) { try { var entity = userRepository.GetUserById(id); if (entity != null && (password != null || password.Trim() != "")) { entity.password = password; userRepository.UpdateUser(entity); userRepository.Save(); AdminUserView userview = new AdminUserView(); userview = Mapper.Map <User, AdminUserView>(entity); userRepository.Save(); return(Request.CreateResponse(HttpStatusCode.OK, userview)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Null object")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage Edituser([FromBody] AdminUserView user) { try { if (user != null) { var entity = userRepository.GetUserById(user.id); if (entity != null) { entity.email = user.email; entity.name = user.name; entity.Role = user.role; entity.teamid = user.team.id; userRepository.UpdateUser(entity); userRepository.Save(); entity = userRepository.GetUserById(user.id); AdminUserView userview = new AdminUserView(); userview = Mapper.Map <User, AdminUserView>(entity); return(Request.CreateResponse(HttpStatusCode.OK, userview)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Not Found")); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Null object")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
static void Main(string[] args) { Console.WriteLine("/////////////////////////////////////////\n Welcome to ATM Managment System \n/////////////////////////////////////////\n"); AdminUserView v = new AdminUserView(); v.ChooseAdminUser(); }
public IActionResult AllUsers(int id = 1) { if (id <= 0) { return(this.NotFound()); } const int ItemPerPage = 12; var viewModel = new AdminUserView(); viewModel.PageNumber = id; viewModel.ItemsPerPage = ItemPerPage; viewModel.CountOfElements = this.adminsService.GetCountOfUsers(); viewModel.Action = AdminAllUsers; viewModel.Users = this.adminsService.GetAllUsers <AdminAllUsersView>(id, ItemPerPage); return(this.View(viewModel)); }
public HttpResponseMessage Adduser([FromBody] User user) { try { if (user != null) { userRepository.InsertUser(user); userRepository.Save(); var entity = userRepository.GetUserById(user.id); AdminUserView userview = new AdminUserView(); userview = Mapper.Map <User, AdminUserView>(entity); userRepository.Save(); return(Request.CreateResponse(HttpStatusCode.OK, userview)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Null object")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }