public async Task <ActionResult> UpdateAdmin(AdminUpdateModel model) { if (ModelState.IsValid) { if (verifLogin(model.userName) || model.userName == model.OldUserName) { var adminJson = await Task.Run(() => JsonConvert.SerializeObject(model)); HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:8080/springboot-crud-rest/api/v1/"); var content = new StringContent(adminJson.ToString(), Encoding.UTF8, "application/json"); System.Diagnostics.Debug.WriteLine(content.ReadAsStringAsync()); HttpResponseMessage response = client.PutAsync("admin/update/" + model.userId, content).Result; System.Diagnostics.Debug.WriteLine(response); return(RedirectToAction("/index")); } else { ViewData["errorLogin"] = "******"; return(View(model)); } } return(View(model)); }
public async Task <AdminModel> UpdateAdminAsync([FromBody] AdminUpdateModel model) { #region Filter var permissionLevel = await _requestContext.GetPermissionLevelAsync(PermissionType.AdminUsers); if (permissionLevel.HasValue && permissionLevel.Value == PermissionLevel.PartnerEdit) { // filter data for current _requestContext.UserId if (model.Id != Guid.Parse(_requestContext.UserId)) { throw LykkeApiErrorException.Forbidden(new LykkeApiErrorCode(nameof(HttpStatusCode.Forbidden))); } } #endregion var(error, admin) = await _adminsService.UpdateAdminAsync( model.Id.ToString(), model.PhoneNumber, model.FirstName, model.LastName, model.Company, model.Department, model.JobTitle, model.IsActive); if (error == AdminServiceResponseError.None) { model.FirstName = model.FirstName.SanitizeName(); model.LastName = model.LastName.SanitizeName(); model.PhoneNumber = model.PhoneNumber.SanitizePhone(); await _auditLogPublisher.PublishAuditLogAsync(_requestContext.UserId, model.ToJson(), ActionType.AdminUpdate); return(_mapper.Map <AdminModel>(admin)); } switch (error) { case AdminServiceResponseError.AdminUserDoesNotExist: throw LykkeApiErrorException.BadRequest(ApiErrorCodes.Service.AdminNotFound); default: throw new ArgumentOutOfRangeException(); } }
public ActionResult UpdateAdmin() { try { AdminUpdateModel admin = new AdminUpdateModel(); UserRegisterModel session = (UserRegisterModel)Session["user"]; admin.OldPasswordVerif = session.password; System.Diagnostics.Debug.WriteLine(admin.OldPasswordVerif); admin.userId = session.userId; admin.userName = session.userName; admin.role = session.role; admin.OldUserName = admin.userName; return(View(admin)); } catch (System.NullReferenceException e) { return(View("Index")); } }
public async Task <AdminModel> UpdateAdminAsync([FromBody] AdminUpdateModel model) { var(error, admin) = await _adminsService.UpdateAdminAsync( model.Id.ToString(), model.PhoneNumber, model.FirstName, model.LastName, model.Company, model.Department, model.JobTitle, model.IsActive); switch (error) { case AdminServiceResponseError.None: return(_mapper.Map <AdminModel>(admin)); case AdminServiceResponseError.AdminUserDoesNotExist: throw LykkeApiErrorException.BadRequest(ApiErrorCodes.Service.AdminNotFound); default: throw new ArgumentOutOfRangeException(); } }
public async Task <CommonResponse> UpdateFlorist(AdminUpdateModel adminUpdateModel) { return(await ExecuteAll <CommonResponse>("Flo.UpdateFlorists", adminUpdateModel)); }
public async Task <CommonResponse> UpdateFlorist(AdminUpdateModel adminUpdateModel) { return(await _adminRepository.UpdateFlorist(adminUpdateModel)); }
public static Admin ConvertToEntity(this AdminUpdateModel updateModel) => new Admin { Name = new FullName(updateModel.FirstName, updateModel.MiddleName, updateModel.LastName) };