public async Task Update(ClientUpdateViewModel model) { using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri(baseUrl); var httpContent = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json"); HttpResponseMessage msg = await client.PutAsync("clients", httpContent); msg.EnsureSuccessStatusCode(); } }
public IActionResult AccountValidation(ClientUpdateViewModel model) { var _user = new AuthenticateResponse { MembershipKey = 1006979, //1007435, EmailAddress = "*****@*****.**", //"*****@*****.**", FirstName = "Tolulope", LastName = "Olusakin", FullName = "Olusakin Tolulope S"//"Funmilayo Ruth Adeyemi", }; if (_user == null) { TempData["SessionTimeOut"] = "You have been logged out due to inactivity. Please login to gain access."; return(RedirectToAction("Login", "Account")); } return(View(model)); }
public async Task <IActionResult> Edit(int id, ClientUpdateViewModel viewModel) { var configuration = new MapperConfiguration(cfg => { cfg.CreateMap <ClientUpdateViewModel, ClientDTO>(); }); IMapper mapper = configuration.CreateMapper(); ClientDTO dto = mapper.Map <ClientDTO>(viewModel); dto.ID = id; try { await _clientService.Update(dto); return(RedirectToAction("Buscar", "Client")); } catch (Exception ex) { ViewBag.Erros = ex.Message; } return(View()); }
public async Task <IActionResult> UpdateClient([FromBody] ClientUpdateViewModel updateModel) { if (ModelState.IsValid) { try { await clientApi.Update(updateModel); return(Json(new { success = true, msg = "Data updated sucessfully!" })); } catch (Exception ex) { return(Json(new { success = false, msg = "an error occured while updating records!" })); } } string errorMsg = ""; foreach (var modelState in ModelState.Values) { errorMsg += "\n" + String.Join('\n', modelState.Errors.Select(e => e.ErrorMessage)); } return(Json(new { success = false, msg = errorMsg })); }
public async Task <IActionResult> AccountValidation(IFormFileCollection files, ClientUpdateViewModel viewmodel) { var model = new ClientUpdateTemp(); var _user = new AuthenticateResponse { MembershipKey = 1006979, //1007435, EmailAddress = "*****@*****.**", //"*****@*****.**", FirstName = "Tolulope", LastName = "Olusakin", FullName = "Olusakin Tolulope S"//"Funmilayo Ruth Adeyemi", }; try { if (files != null) { int index = 0; foreach (var file in files) { if (file.Length > 0) { var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"'); byte[] fileBytes = null; using (var fileStream = file.OpenReadStream()) using (var ms = new MemoryStream()) { fileStream.CopyTo(ms); fileBytes = ms.ToArray(); } if (index == 0) { model.Passport = fileBytes; } else if (index == 1) { model.Signature = fileBytes; } else if (index == 2) { model.Thumbprint = fileBytes; } else if (index == 3) { model.ValidID = fileBytes; } index++; } } model.MembershipNumber = _user.MembershipKey; model.EvaluationStatus = ""; model.ProgressStatus = "Pending"; model.TaxNumber = viewmodel.TaxNumber; model.Jurisdiction = viewmodel.Jurisdiction; model.IsKYCApproved = false; model.IsPassportApproved = false; model.IsSignatureApproved = false; model.IsThumbprintApproved = false; model.IsValidIdApproved = false; model.DateUpdated = DateTime.Now; //check if client already has a record in the table var clientquery = db.ClientUpdateTemps.Where(s => s.MembershipNumber.Equals(_user.MembershipKey)).FirstOrDefault(); if (clientquery != null) { db.ClientUpdateTemps.Update(model); await db.SaveChangesAsync(); var msg = "Success: your details have been updated!"; viewmodel.SuccessMessage = msg; //TempData["message"] = ViewBag.Message = msg; TempData["message"] = true; //return RedirectToAction("ClientUpdate", "SelfService", viewmodel.SuccessMessage); return(AccountValidation(viewmodel)); } else { db.ClientUpdateTemps.Add(model); await db.SaveChangesAsync(); var msg = "Success: your details have been updated!"; viewmodel.SuccessMessage = msg; TempData["message"] = true; //return RedirectToAction("ClientUpdate", "SelfService", viewmodel); return(AccountValidation(viewmodel)); } } } catch (Exception ex) { viewmodel.ErrorMessage = ex.Message; TempData["message"] = false; Utilities.ProcessError(ex, _contentRootPath); _logger.LogError(null, ex, ex.Message); } return(View()); }
public WelcomeModule() { #region LoginRemote Get["/"] = _ => { return(View["Login"]); }; Get["Login"] = _ => { //生成CSRF token. this.CreateNewCsrfToken(); return(View["Login"]); }; Post["Login"] = p => { //CSRF token 检验 this.ValidateCsrfToken(); var loginModel = this.Bind <LoginModel>(); var model = LoginViewModel.Verify(UserManageViewModel.GetData(), loginModel.username, loginModel.password); if (model != null) { Guid guid = Guid.NewGuid(); Context.Request.Session[guid.ToString()] = model; return(this.LoginAndRedirect(guid, fallbackRedirectUrl: "/index")); } return(View["Login"]); }; Get["LoginOut"] = _ => { Session.DeleteAll(); return(this.LogoutAndRedirect("~/")); }; #endregion #region ClientUpdate Get["api/RequestNewestPackageUrl/{HopitalID}/{OldNumber}"] = p => { RequestNewestPackageUrlResponseModel res = ClientUpdateViewModel.RequestNewestPackageUrl(p.HopitalID, p.OldNumber); return(Response.AsJson <RequestNewestPackageUrlResponseModel>(res)); }; #endregion #region TEST Get["/down/{name}"] = _ => { string fileName = _.name; return(Response.AsFile(@"Content\uploads\123.txt")); }; Get["/show"] = _ => { var uploadDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content", "uploads"); var folder = new DirectoryInfo(uploadDirectory); IList <string> files = new List <string>(); foreach (var file in folder.GetFiles()) { files.Add(file.Name); } return(View["Show", files]); }; #endregion }
public async Task <IActionResult> Update([FromBody] ClientUpdateViewModel item) { await _commandFunctionality.UpdateAsync(Mapper.Map <ClientUpdateCommand>(item)); return(StatusCode(StatusCodes.Status201Created)); }