public List<Task> GetAllTasksByProfile(UserVm usuario) { List<Task> tarefasGrupos = new List<Task>(); foreach (string grupo in usuario.Groups) tarefasGrupos.AddRange(Tarefas.Where(o => o.Responsavel == grupo)); return tarefasGrupos; }
public async Task <IActionResult> DeleteUser(string id) { var user = await _userManager.FindByIdAsync(id); if (user == null) { return(NotFound()); } var adminUsers = await _userManager.GetUsersInRoleAsync(Constants.SystemConstants.Roles.Admin); var otherUsers = adminUsers.Where(x => x.Id != id).ToList(); if (otherUsers.Count == 0) { return(BadRequest(new ApiBadRequestResponse("You cannot remove the only admin user remaining."))); } var result = await _userManager.DeleteAsync(user); if (result.Succeeded) { var uservm = new UserVm() { Id = user.Id, UserName = user.UserName, Dob = user.Dob, Email = user.Email, PhoneNumber = user.PhoneNumber, FirstName = user.FirstName, LastName = user.LastName, CreateDate = user.CreateDate }; return(Ok(uservm)); } return(BadRequest(new ApiBadRequestResponse(result))); }
public ActionResult Login(UserVm model) { if (!ModelState.IsValid) { return(View(model)); } var user = _userRepository.GetByMail(model.Mail); if (user != null) { Session["User"] = user; if (user.Password.Equals(model.Password)) { return(RedirectToAction("Index", "Rating")); } ModelState.AddModelError("incorreto", "Email ou senha incorretos."); return(View(model)); } ModelState.AddModelError("Mail", "Usuario não cadastrado."); return(View(model)); }
public object Register([FromBody] UserVm userVm) { try { _logger.LogInfo($"{MethodInfoHelper.GetCurrentMethodName()} started."); var userConfirmation = _registerService.CreateUser(userVm); if (!string.IsNullOrEmpty(userConfirmation.EmailAddress)) { return(Ok(new { message = "User was succesfully recorded!" })); } } catch (AppException ex) { _logger.LogError($"{MethodInfoHelper.GetCurrentMethodName()} failed.", ex); throw; } finally { _logger.LogInfo($"{MethodInfoHelper.GetCurrentMethodName()} ended."); } return(new { message = "Something went wrong please try again" }); }
public async void NewMessageUpdateUserChatsAsync(MessageVm message) { try { UserVm senderInfo = await loadUsersService.GetUserAsync(message.SenderId.GetValueOrDefault()).ConfigureAwait(false); IEnumerable <long> usersId = await loadChatsService.GetChatUsersIdAsync(message.ConversationId.GetValueOrDefault()).ConfigureAwait(false); foreach (long userId in usersId) { List <ConversationPreviewVm> cachedChats = (await GetUserChatsAsync(userId).ConfigureAwait(false))?.ToList(); if (cachedChats == null || cachedChats.All(opt => opt.ConversationId != message.ConversationId)) { cachedChats = (await loadChatsService.GetUserChatPreviewAsync(userId, DateTime.UtcNow.ToUnixTime()).ConfigureAwait(false))?.ToList(); UpdateUserChats(userId, cachedChats); continue; } ConversationPreviewVm updatedChat = cachedChats.FirstOrDefault(opt => opt.ConversationId == message.ConversationId); if (updatedChat != null) { updatedChat.LastMessageSenderId = message.SenderId; updatedChat.LastMessageTime = message.SendingTime; updatedChat.LastMessageSenderName = senderInfo.NameFirst; updatedChat.PreviewText = message.Text; updatedChat.LastMessageId = message.GlobalId; updatedChat.Read = false; updatedChat.AttachmentType = (AttachmentType?)message.Attachments?.FirstOrDefault()?.Type ?? null; UpdateUserChats(userId, cachedChats); } } } catch (Exception ex) { Logger.WriteLog(ex); } }
public static BaseViewModelMain GetView(string s) { BaseViewModelMain viewContent = null; switch (s) { case "Control": viewContent = new ControlVm(); break; case "Report": viewContent = new ReportVm(); break; case "Route": viewContent = new RouteVm(); break; case "Train": viewContent = new TrainVm(); break; case "Station": viewContent = new StationVm(); break; case "PinLocation": viewContent = new PinLocationVm(); break; case "TimeTable": viewContent = new TimeTableVm(); break; case "User": viewContent = new UserVm(); break; } return(viewContent); }
public async Task <Response> CreateResponseAsync() { UserVm editableUser = await updateUsersService.EditUserAsync(request.User, clientConnection.UserId.GetValueOrDefault()).ConfigureAwait(false); BlockSegmentVm segment = await BlockSegmentsService.Instance.CreateEditUserSegmentAsync( editableUser, NodeSettings.Configs.Node.Id, NodeData.Instance.NodeKeys.SignPrivateKey, NodeData.Instance.NodeKeys.SymmetricKey, NodeData.Instance.NodeKeys.Password, NodeData.Instance.NodeKeys.KeyId).ConfigureAwait(false); BlockGenerationHelper.Instance.AddSegment(segment); EditUserBlockData editBlockData = (EditUserBlockData)segment.PublicData; ShortUser shortUser = new ShortUser { PrivateData = segment.PrivateData, UserId = editBlockData.UserId }; nodeNoticeService.SendEditUsersNodeNoticeAsync(shortUser, segment); UsersConversationsCacheService.Instance.UserEditedUpdateUserDialogsAsync(editableUser); return(new UserResponse(request.RequestId, editableUser)); }
public async Task <ApiResult <UserVm> > GetById(Guid id) { var user = await _userManager.FindByIdAsync(id.ToString()); if (user == null) { return(new ApiErrorResult <UserVm>("User không tồn tại")); } var roles = await _userManager.GetRolesAsync(user); var userVm = new UserVm() { Email = user.Email, PhoneNumber = user.PhoneNumber, FirstName = user.FirstName, Dob = user.Dob, Id = user.Id, LastName = user.LastName, UserName = user.UserName, Roles = roles }; return(new ApiSuccessResult <UserVm>(userVm)); }
public async Task <Response> CreateResponseAsync() { try { clientConnection.FileAccessToken = RandomExtensions.NextString(64); TokensResponse response = default; if (request.DeviceTokenId != null && !string.IsNullOrWhiteSpace(request.DeviceTokenId)) { await tokensService.SetDeviceTokenIdNullAsync(request.DeviceTokenId).ConfigureAwait(false); } UserVm user = null; switch (request.LoginType) { case LoginType.VerificationCode: { TokenVm token = null; if (request.UidType == UidType.Phone) { token = await tokensService.PhoneVCodeCreateTokenPairAsync(request.Uid, request.VCode.GetValueOrDefault(), request.DeviceTokenId).ConfigureAwait(false); } else if (request.UidType == UidType.Email) { token = await tokensService.EmailVCodeCreateTokenPairAsync(request.Uid, request.VCode.GetValueOrDefault(), request.DeviceTokenId).ConfigureAwait(false); } else if (request.UidType == UidType.UserId) { token = await tokensService.UserIdVCodeCreateTokenPairAsync(Convert.ToInt64(request.Uid), request.VCode.GetValueOrDefault(), request.DeviceTokenId).ConfigureAwait(false); } clientConnection.UserId = token.UserId; token = await tokensService.UpdateTokenDataAsync(request.OSName, request.DeviceName, request.AppName, clientConnection.ClientIP.ToString(), token).ConfigureAwait(false); clientConnection.CurrentToken = token; user = await loadUsersService.GetUserInformationAsync(token.UserId).ConfigureAwait(false); response = new TokensResponse(request.RequestId, token, clientConnection.FileAccessToken, null, user); noticeService.SendNewSessionNoticeAsync(clientConnection); } break; case LoginType.AccessTokenAndUserId: { TokenVm token = new TokenVm { UserId = request.Token.UserId, AccessToken = request.Token.AccessToken, RefreshToken = request.Token.RefreshToken, DeviceTokenId = request.DeviceTokenId }; token = await tokensService.CheckTokenAsync(token, NodeSettings.Configs.Node.Id).ConfigureAwait(false); clientConnection.UserId = token.UserId; token = await tokensService.UpdateTokenDataAsync(request.OSName, request.DeviceName, request.AppName, clientConnection.ClientIP.ToString(), token).ConfigureAwait(false); clientConnection.CurrentToken = token; user = await loadUsersService.GetUserInformationAsync(token.UserId).ConfigureAwait(false); response = new TokensResponse(request.RequestId, token, clientConnection.FileAccessToken, null, user); } break; case LoginType.Password: { ValuePair <TokenVm, string> tokenPasswordPair; if (request.UidType == UidType.Phone) { tokenPasswordPair = await tokensService.PhonePasswordCreateTokenPairAsync(request.Uid, request.Password, request.DeviceTokenId).ConfigureAwait(false); } else if (request.UidType == UidType.Email) { tokenPasswordPair = await tokensService.EmailPasswordCreateTokenPairAsync(request.Uid, request.Password, request.DeviceTokenId).ConfigureAwait(false); } else if (request.UidType == UidType.UserId) { tokenPasswordPair = await tokensService.UserIdPasswordCreateTokenPairAsync(Convert.ToInt64(request.Uid), request.Password, request.DeviceTokenId).ConfigureAwait(false); } else { var errorObject = new { UidType = "Unknown UidType." }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ErrorCode.WrongArgumentError)); } clientConnection.UserId = tokenPasswordPair.FirstValue.UserId; tokenPasswordPair.FirstValue = await tokensService.UpdateTokenDataAsync(request.OSName, request.DeviceName, request.AppName, clientConnection.ClientIP.ToString(), tokenPasswordPair.FirstValue) .ConfigureAwait(false); clientConnection.CurrentToken = tokenPasswordPair.FirstValue; user = await loadUsersService.GetUserInformationAsync(clientConnection.UserId.Value).ConfigureAwait(false); response = new TokensResponse( request.RequestId, tokenPasswordPair.FirstValue, clientConnection.FileAccessToken, tokenPasswordPair.SecondValue, user); noticeService.SendNewSessionNoticeAsync(clientConnection); } break; } clientConnection.Confirmed = user.Confirmed; clientConnection.Banned = user.Banned; connectionsService.AddOrUpdateUserConnection(clientConnection.UserId.Value, clientConnection); SendPendingMessagesAsync(); return(response); } catch (InvalidTokenException ex) { Logger.WriteLog(ex, request); return(new ResultResponse(request.RequestId, "Invalid token.", ErrorCode.InvalidAccessToken)); } catch (WrongVerificationCodeException ex) { Logger.WriteLog(ex, request); return(new ResultResponse(request.RequestId, "Invalid verification code.", ErrorCode.WrongVerificationCode)); } catch (UserNotFoundException ex) { Logger.WriteLog(ex, request); return(new ResultResponse(request.RequestId, "User not found.", ErrorCode.UserNotFound)); } catch (CreateTokenPairException ex) { Logger.WriteLog(ex, request); return(new ResultResponse(request.RequestId, "Login failed.", ErrorCode.AuthorizationProblem)); } catch (TokensTimeoutException ex) { Logger.WriteLog(ex, request); await noticeService.SendNeedLoginNoticeAsync(clientConnection).ConfigureAwait(false); return(new ResultResponse(request.RequestId, "Refresh token expired.", ErrorCode.RefreshTokenTimeout)); } catch (UserFromAnotherNodeException ex) { await MetricsHelper.Instance.SetCrossNodeApiInvolvedAsync(request.RequestId).ConfigureAwait(false); var userToken = await nodeRequestSender.CheckTokenAsync( request.Token.UserId, request.Token, ex.NodeId.GetValueOrDefault()).ConfigureAwait(false); if (userToken != null) { clientConnection.UserId = userToken.FirstValue.UserId; clientConnection.ProxyNodeWebSocket = connectionsService.GetNodeConnection(ex.NodeId.GetValueOrDefault()).NodeWebSocket; connectionsService.AddOrUpdateUserConnection(clientConnection.UserId.Value, clientConnection); return(new TokensResponse(request.RequestId, userToken.FirstValue, clientConnection.FileAccessToken, null, userToken.SecondValue)); } return(new ResultResponse(request.RequestId, "Login failed.", ErrorCode.AuthorizationProblem)); } catch (Exception ex) { Logger.WriteLog(ex, request); return(new ResultResponse(request.RequestId, null, ErrorCode.UnknownError)); } }
public IActionResult VerifyUser([FromBody] UserVm login) { IEnumerable <Membership> _member = _memberservice.verif(login.Email, login.Password); return(new OkObjectResult(_member)); }
public IActionResult Update(int id, UserVm item) { _service.Update(id, item); return(NoContent()); }
public ActionResult peAppWvUsers_Update([DataSourceRequest] DataSourceRequest request, UserVm vm) { if (ModelState.IsValid) { db.peAppWvUsers.Where(u => u.Id == vm.Id).Update(u => new peAppWvUser { code = vm.code, name = vm.name, dept = vm.dept, SubDept = vm.SubDept, password = vm.password }); db.SaveChanges(); } return(Json(new[] { vm }.ToDataSourceResult(request, ModelState))); }
public async Task Put(int userId, [FromBody] UserVm value) { _dbContext.Users.Update(_mapper.Map <User>(value)); await _dbContext.SaveChangesAsync(); }
private void BindFormFields() { this.Vm.Id = Request.QueryString["id"]; this.Vm = this.model.GetUserById(this.Vm); this.ViewModelToControl(this.Vm); }
private User ViewToDomain(UserVm user) { return(UserMapper.Mapper().Map <User>(user)); }
public IActionResult VerifCode(UserVm userVm) { if (userVm.VerifyCode != null) { var jsonUserVM = JsonConvert.SerializeObject(userVm); var buffer = System.Text.Encoding.UTF8.GetBytes(jsonUserVM); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var result = client.PostAsync("account/code/", byteContent).Result; if (result.IsSuccessStatusCode) { var data = result.Content.ReadAsStringAsync().Result; if (data != "") { var json = JsonConvert.DeserializeObject(data).ToString(); var account = JsonConvert.DeserializeObject <UserVm>(json); if (account.RoleName == "HR" || account.RoleName == "Sales" || account.RoleName == "Admin") { HttpContext.Session.SetString("id", account.Id); HttpContext.Session.SetString("uname", account.Username); HttpContext.Session.SetString("email", account.Email); HttpContext.Session.SetString("lvl", account.RoleName); if (account.RoleName == "Admin") { return(Json(new { status = true, msg = "Login Successfully !", acc = "Admin" })); } else if (account.RoleName == "Sales") { return(Json(new { status = true, msg = "Login Successfully !", acc = "Sales" })); } else { return(Json(new { status = true, msg = "Login Successfully !", acc = "HR" })); } } else { return(Json(new { status = false, msg = "Invalid Username or Password!" })); } } else { return(Json(new { status = false, msg = "Username Not Found!" })); } //var data = result.Content.ReadAsStringAsync().Result; //var json = JsonConvert.DeserializeObject(data).ToString(); //var account = JsonConvert.DeserializeObject<UserVM>(json); //var dataLogin = new UserVM() //{ // Email = account.Email, // Password = account.Password //}; //this.Validate(dataLogin); //return Json(new { status = true, code = result, msg = "Login Success! " }); } else { return(Json(new { status = false, msg = "Your Code is Wrong!" })); } } else { return(Json(new { status = false, msg = "Something Wrong!" })); } }
public async Task <UserVm> SaveUser(UserVm user) { return(await(user.Id > 0 ? Update(user) : InsertAsync(user))); }
public ActionResult CreateAccount(UserVm model, HttpPostedFileBase file) { // Initialise the database Db db = new Db(); // Check model state if (!ModelState.IsValid) { return(View("Index", model)); } // Check if username is available if (db.users.Any(x => x.Username.Equals(model.Username))) { ModelState.AddModelError("", "Username " + model.Username + " is taken"); model.Username = ""; return(View("Index", model)); } // Create user DTO UserDto userDto = new UserDto() { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, Username = model.Username, Password = model.Password }; // Add to DTO db.users.Add(userDto); // Save changes db.SaveChanges(); // Get last inserted id int userId = userDto.Id; // Log the user in FormsAuthentication.SetAuthCookie(model.Username, false); // Set upload directory var uploadDir = new DirectoryInfo(string.Format("{0}Uploads", Server.MapPath(@"\"))); // Check if file was uploaded if (file != null && file.ContentLength > 0) { string ext = file.ContentType.ToLower(); if (ext != "image/jpg" && ext != "image/jpeg" && ext != "image/gif" && ext != "image/png") { ModelState.AddModelError("", "The image was not uploaded - invalid image"); return(View("Index", model)); } // Set image name string imageName = userId + ".jpg"; // Set image path var path = (string.Format("{0}\\{1}", uploadDir, imageName)); // Save image to the server file.SaveAs(path); } // Redirect return(Redirect("~/" + model.Username)); }
public void AddUser_Should_Throws_Exception_When_Command_Null() { UserVm vm = null; var actual = this.Sut.AddUser(vm); }
public IActionResult DeleteUser(int userId) { var userVm = UserVm.MapToViewModel(UserBlProvider.GetUserById(userId)); return(PartialView("_DeleteUser", userVm)); }
public IActionResult Validate(UserVm userVm) { if (userVm.Username == null) { // Login var jsonUserVM = JsonConvert.SerializeObject(userVm); var buffer = System.Text.Encoding.UTF8.GetBytes(jsonUserVM); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var resTask = client.PostAsync("account/login/", byteContent); resTask.Wait(); var result = resTask.Result; if (result.IsSuccessStatusCode) { var data = result.Content.ReadAsStringAsync().Result; if (data != null) { HttpContext.Session.SetString("token", "Bearer " + data); var handler = new JwtSecurityTokenHandler(); var tokenS = handler.ReadJwtToken(data); //var user = new UserVM(); //user.Id = tokenS.Claims.First(claim => claim.Type == "Id").Value; //user.Username = tokenS.Claims.First(claim => claim.Type == "Username").Value; //user.Email = tokenS.Claims.First(claim => claim.Type == "Email").Value; //user.RoleName = tokenS.Claims.First(claim => claim.Type == "RoleName").Value; //user.VerifyCode = tokenS.Claims.First(claim => claim.Type == "VerifyCode").Value; var jwtPayloadSer = JsonConvert.SerializeObject(tokenS.Payload.ToDictionary(x => x.Key, x => x.Value)); var jwtPayloadDes = JsonConvert.DeserializeObject(jwtPayloadSer).ToString(); var account = JsonConvert.DeserializeObject <UserVm>(jwtPayloadSer); //var json = JsonConvert.DeserializeObject(data).ToString(); //var account = JsonConvert.DeserializeObject<UserVM>(json); //if (BC.Verify(userVM.Password, account.Password) && (account.RoleName == "Admin" || account.RoleName == "Sales")) if (!account.VerifyCode.Equals("")) { if (userVm.VerifyCode != account.VerifyCode) { return(Json(new { status = true, msg = "Check your Code" })); } } else if (account.RoleName == "Admin" || account.RoleName == "Sales" || account.RoleName == "HR") { HttpContext.Session.SetString("id", account.Id); HttpContext.Session.SetString("uname", account.Username); HttpContext.Session.SetString("email", account.Email); HttpContext.Session.SetString("lvl", account.RoleName); if (account.RoleName == "Admin") { return(Json(new { status = true, msg = "Login Successfully !", acc = "Admin" })); } else if (account.RoleName == "Sales") { return(Json(new { status = true, msg = "Login Successfully !", acc = "Sales" })); } else { return(Json(new { status = true, msg = "Login Successfully !", acc = "HR" })); } } else { return(Json(new { status = false, msg = "Invalid Username or Password!" })); } } else { return(Json(new { status = false, msg = "Username Not Found!" })); } } else { //return RedirectToAction("Login","Auth"); return(Json(new { status = false, msg = "Something Wrong!" })); } } else if (userVm.Username != null) { // Register var json = JsonConvert.SerializeObject(userVm); var buffer = System.Text.Encoding.UTF8.GetBytes(json); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var result = client.PostAsync("account/register/", byteContent).Result; if (result.IsSuccessStatusCode) { return(Json(new { status = true, code = result, msg = "Register Success! " })); } else { return(Json(new { status = false, msg = "Something Wrong!" })); } } return(Redirect("/login")); }
/* * User */ /// <summary> /// Map using Automapper /// </summary> public static UserDto MapToDto(this UserVm userVm) { return(Mapper.Map <UserVm, UserDto>(userVm)); }
public async void SendDialogMessagesReadNoticeAsync(IEnumerable <Guid> messagesId, UserVm senderUser, UserVm receiverUser) { try { List <long> nodesId = new List <long> { senderUser.NodeId.GetValueOrDefault(), receiverUser.NodeId.GetValueOrDefault() }; MessagesReadNodeNotice notice = new MessagesReadNodeNotice( messagesId, ConversationType.Dialog, receiverUser.Id.GetValueOrDefault(), senderUser.Id.GetValueOrDefault()); await SendNoticeToNodesAsync(notice, nodesId).ConfigureAwait(false); } catch (Exception ex) { Logger.WriteLog(ex); } }
public async Task Post([FromBody] UserVm value) { await _dbContext.Users.AddAsync(_mapper.Map <User>(value)); await _dbContext.SaveChangesAsync(); }
public async Task <Response> CreateResponseAsync() { if (!NodeSettings.Configs.Node.UserRegistrationAllowed) { return(new ResultResponse(request.RequestId, "User registration is not allowed.", ErrorCode.PermissionDenied)); } UserVm user = request.User; try { VerificationCodeInfo verificationCode = null; if (!request.User.Phones.IsNullOrEmpty() && request.User.Emails.IsNullOrEmpty()) { if (NodeSettings.Configs.Node.RegistrationMethod == RegistrationMethod.EmailRequired) { var errorObject = new { Email = "Email required" }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ErrorCode.WrongArgumentError)); } if (await loadUsersService.IsPhoneExistsAsync(request.User.Phones.FirstOrDefault().FullNumber).ConfigureAwait(false)) { var errorObject = new { Phone = "Phone already exists" }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ErrorCode.WrongArgumentError)); } verificationCode = await verificationCodesService.GetUserVerificationCodeAsync(request.User.Phones.FirstOrDefault().FullNumber).ConfigureAwait(false); } else if (request.User.Phones.IsNullOrEmpty() && !request.User.Emails.IsNullOrEmpty()) { if (NodeSettings.Configs.Node.RegistrationMethod == RegistrationMethod.PhoneRequired) { var errorObject = new { Email = "Phone required" }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ErrorCode.WrongArgumentError)); } if (await loadUsersService.IsEmailExistsAsync(request.User.Emails.FirstOrDefault()).ConfigureAwait(false)) { var errorObject = new { Email = "Email already exists." }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ErrorCode.WrongArgumentError)); } verificationCode = await verificationCodesService.GetUserVerificationCodeAsync(request.User.Emails.FirstOrDefault()).ConfigureAwait(false); } else { if (NodeSettings.Configs.Node.RegistrationMethod != RegistrationMethod.NothingRequired) { var errorObject = new { Email = "Email only or phone only", Phone = "Email only or phone only" }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ErrorCode.WrongArgumentError)); } } if (verificationCode != null && verificationCode.VCode != request.VCode && (!request.User.Emails.IsNullOrEmpty() || !request.User.Phones.IsNullOrEmpty())) { var errorObject = new { VCode = "Wrong verification code" }; return(new ResultResponse(request.RequestId, ObjectSerializer.ObjectToJson(errorObject), ErrorCode.WrongVerificationCode)); } ValuePair <UserVm, string> userPasswordPair = await createUsersService.CreateNewUserAsync(user, NodeSettings.Configs.Node.Id, NodeSettings.Configs.ConfirmUsers).ConfigureAwait(false); TokenVm tempTokens = await tokensService.CreateTokenPairByUserIdAsync(userPasswordPair.FirstValue.Id.GetValueOrDefault(), false, 30 * 60).ConfigureAwait(false); clientConn.FileAccessToken = RandomExtensions.NextString(64); BlockSegmentVm segment = await BlockSegmentsService.Instance.CreateNewUserSegmentAsync( userPasswordPair.FirstValue, NodeSettings.Configs.Node.Id, NodeData.Instance.NodeKeys.SignPrivateKey, NodeData.Instance.NodeKeys.SymmetricKey, NodeData.Instance.NodeKeys.Password, NodeData.Instance.NodeKeys.KeyId).ConfigureAwait(false); BlockGenerationHelper.Instance.AddSegment(segment); ShortUser shortUser = new ShortUser { UserId = userPasswordPair.FirstValue.Id.GetValueOrDefault(), PrivateData = segment.PrivateData }; nodeNoticeService.SendNewUsersNodeNoticeAsync(shortUser, segment); return(new TokensResponse( request.RequestId, userPasswordPair.FirstValue, tempTokens.AccessToken, tempTokens.RefreshToken, clientConn.FileAccessToken, userPasswordPair.SecondValue)); } catch (CreateNewUserException ex) { Logger.WriteLog(ex, request); return(new ResultResponse(request.RequestId, ex.Message, ErrorCode.UnknownError)); } }
public ActionResult peAppWvUsers_Create([DataSourceRequest] DataSourceRequest request, UserVm vm) { if (ModelState.IsValid) { var entity = new peAppWvUser { code = vm.code, name = vm.name, // 6个1 password = "******", dept = vm.dept, SubDept = vm.SubDept, }; db.peAppWvUsers.Add(entity); db.SaveChanges(); vm.Id = entity.Id; } return(Json(new[] { vm }.ToDataSourceResult(request, ModelState))); }
public UserVm Update(UserVm user) { var mUser = _userService.Update(user); return(mUser); }
public ActionResult peAppWvUsers_Destroy([DataSourceRequest] DataSourceRequest request, UserVm vm) { if (ModelState.IsValid) { var entity = new peAppWvUser { Id = vm.Id, code = vm.code, name = vm.name, dept = vm.dept, SubDept = vm.SubDept, password = vm.password }; db.peAppWvUsers.Attach(entity); db.peAppWvUsers.Remove(entity); db.SaveChanges(); } return(Json(new[] { vm }.ToDataSourceResult(request, ModelState))); }
public IActionResult Create(UserVm item) { var id = _service.Create(item); return(CreatedAtRoute("GetUser", new { id = item.Id }, item)); }
public async Task <ActionResult> Settings(UserVm userVm) { _serviceFacade.UserService.ChangeSettings(userVm.MapToDto()); return(RedirectToAction("UserPage")); }
public ActionResult Edit(UserVm newUser) { this._dataService.UpdateUser(newUser.Id, Mapper.Map <UserVm, UserDto>(newUser)); return(RedirectToAction("Index", "User")); }