public async Task <IHttpActionResult> Edit([FromBody] ClientEditModel model) { if (!ModelState.IsValid) { return(Content(HttpStatusCode.BadRequest, GetValidationErrors())); } var client = await _clientService.FindById(model.Id); if (client == null) { throw new ArgumentNullException(nameof(client)); } client.FirstName = model.FirstName; client.UserLoginData.OriginUsername = model.CardNumber; client.UserLoginData.UserName = model.CardNumber.Replace(" ", string.Empty); client.LastName = model.LastName; client.PhoneNumber = model.PhoneNumber; client.Address = model.Address; client.Email = model.Email; client.City = model.City; _clientService.Edit(client); _loggerService.Log(UserId, ActionType.Create, $"Cliend account edited - {model.CardNumber}"); return(Ok()); }
public async Task <IActionResult> Edit(int id, ClientEditModel clientModel) { if (!ModelState.IsValid) { return(View()); } HttpResponseMessage getResponse = await httpClient.GetAsync($"{ClientsAPIEndpoint}/{id}"); Client ogClient = await getResponse.Content.ReadAsAsync <Client>(); // Client mappedClient = _mapper.Map(clientModel, ogClient); ogClient.FirstName = clientModel.FirstName; ogClient.LastName = clientModel.LastName; ogClient.Email = clientModel.Email; ogClient.Password = clientModel.Password; HttpResponseMessage response = await httpClient.PutAsJsonAsync($"{ClientsAPIEndpoint}/{id}", ogClient); try { response.EnsureSuccessStatusCode(); return(RedirectToAction(nameof(ClientsController.Index))); } catch (System.Exception) { ModelState.AddModelError("", await response.Content.ReadAsStringAsync()); return(View()); } }
private void Edit(ClientEditModel clientEditModel) { ClientInfoViewModel viewModel = GetClientInfoViewModel(clientEditModel); ClientInfoControl control = new ClientInfoControl(viewModel); Window window = WindowFactory.CreateByContentsSize(control); viewModel.ClientEdited += (s, e) => { ClientEditDTO clientEditDTO = Mapper.Map <ClientEditModel, ClientEditDTO>(e.Client); using (IClientService service = factory.CreateClientService()) { ServiceMessage serviceMessage = service.Update(clientEditDTO); RaiseReceivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message); if (serviceMessage.IsSuccessful) { window.Close(); Notify(); } } }; window.Show(); }
public UIElement GetDisplayElement() { ManageClientsViewModel viewModel = GetManageClientsViewModel(this, facade); ManageClientsControl control = new ManageClientsControl(viewModel); viewModel.ClientSelectRequest += (s, e) => { string login = e.Client.Login; using (IClientService service = factory.CreateClientService()) { DataServiceMessage <ClientEditDTO> serviceMessage = service.GetClientInfo(login); RaiseReceivedMessageEvent(serviceMessage); if (serviceMessage.IsSuccessful) { ClientEditDTO clientEditDTO = serviceMessage.Data; ClientEditModel clientEditModel = Mapper.Map <ClientEditDTO, ClientEditModel>(clientEditDTO); Edit(clientEditModel); } } }; return(control); }
public ActionResult Create(ClientEditModel ce) { Client newClient = new Client(ce); newClient.CityId = 1; newClient.DateCreated = DateTime.UtcNow.AddHours(8); // ce.CreatedByUserId = ""; db.Clients.Add(newClient); SeniorCitizen newSC = new SeniorCitizen(); newSC.Status = "Pending"; newSC.Client = newClient; db.SeniorCitizens.Add(newSC); ce.ClientBeneficiaries.ForEach(c => c.ClientId = newClient.ClientId); ce.ClientBeneficiaries.ForEach(c => db.ClientBeneficiary.Add(c)); if (db.SaveChanges() > 1) { return(RedirectToAction("Index", "SeniorCitizens", null)); } else { return(View(ce)); } }
public async Task <ActionResult <ClientViewModel> > PutClient(string id, ClientEditModel clientModel) { Client client = await _clientsRepository.FindByIdAsync(id); if (client is null) { return(BadRequest($"El cliente con identificación {id} no se encuentra registrado.")); } _mapper.Map(clientModel, client); client.PublishEvent(new UpdatedClient(client)); _clientsRepository.Update(client); try { await _unitWork.SaveAsync(); } catch (DbUpdateConcurrencyException) { if (!ClientExists(id)) { return(NotFound( $"Actualización fallida. El cliente con identificación {id} no se encuentra registrado.")); } throw; } return(_mapper.Map <ClientViewModel>(client)); }
public ActionResult Edit(int id) { CompanyManager <Company> clientManager = new CompanyManager <Company>(new CompanyStore <Company>()); Company c = clientManager.GetClientByID(id); ClientEditModel ClientModel = (ClientEditModel)AutoMapper.Mapper.Map <ClientEditModel>(c); return(View("Edit", ClientModel)); }
public ActionResult Edit(ClientEditModel m) { CompanyManager <Company> clientManager = new CompanyManager <Company>(new CompanyStore <Company>()); Company c = AutoMapper.Mapper.Map <Company>(m); clientManager.UpdateClient(c); return(View(m)); }
private void Edit(ClientEditModel clientEditModel) { ClientEditDTO clientEditDTO = Mapper.Map <ClientEditModel, ClientEditDTO>(clientEditModel); using (IClientService service = factory.CreateClientService()) { ServiceMessage serviceMessage = service.Update(clientEditDTO); RaiseReceivedMessageEvent(serviceMessage); } }
private void RaiseClientEditedEvent(ClientEditModel client) { var handler = ClientEdited; if (handler != null) { ClientEditEventArgs e = new ClientEditEventArgs(client); handler(this, e); } }
public ActionResult ApplySP() { string username = User.Identity.GetUserName(); ApplicationUser au = db.Users.FirstOrDefault(u => u.UserName == username); ClientEditModel ce = new ClientEditModel(); ce.GivenName = au.GivenName; ce.MiddleName = au.MiddleName; ce.SurName = au.LastName; return(View(ce)); }
public IActionResult Update(ClientEditModel clientModel, int clientId) { if (ModelState.IsValid) { var id = _context.Clients.Update(_mapper.Map <Client>(clientModel)); _context.SaveChanges(); return(RedirectToAction("ClientList", "Client")); } else { return(View()); } }
public ClientInfoViewModel(ClientEditModel client) { this.client = client; this.clientForEdit = new ClientEditModel { Login = client.Login, FirstName = client.FirstName, LastName = client.LastName, PhoneNumber = client.PhoneNumber, DateOfBirth = client.DateOfBirth }; this.SaveChangesCommand = new DelegateCommand(() => RaiseClientEditedEvent(clientForEdit), CanSave); this.UndoCommand = new DelegateCommand(Undo, obj => IsDirty()); this.Bets = new ObservableCollection <BetDisplayModel>(client.Bets); }
public ActionResult ApplySC() { string username = User.Identity.GetUserName(); ApplicationUser au = db.Users.FirstOrDefault(u => u.UserName == username); /*if (au.Client != null) * { * return RedirectToAction("Apply"); * }*/ ClientEditModel ce = new ClientEditModel(); ce.GivenName = au.GivenName; ce.MiddleName = au.MiddleName; ce.SurName = au.LastName; return(View(ce)); }
public void Edit_Test() { Client cl = new ccEntities().Clients.Single(x => x.FirstName == "Client1"); ActionResult actual = Target.Edit(cl.Id); ViewResult actualView = (ViewResult)actual; Assert.IsNotNull(actual, "action result can not be null"); Assert.IsNotNull(actualView, "action result can not be null"); Assert.IsNotNull(actualView.Model, "action result can not be null"); ClientEditModel cm = (ClientEditModel)actualView.Model; Assert.IsTrue(cm.Data.FirstName == "Client1", "Client name must be Client1"); }
public void EditPost_Test() { Client cl = new ccEntities().Clients.Single(x => x.FirstName == "Client1"); ClientEditModel cm = new ClientEditModel(); cm.Data = cl; cl.City = "changed city"; ActionResult actual = Target.Edit(cl.Id); Assert.IsNotNull(actual, "action result can not be null"); string actionName = (((System.Web.Mvc.RedirectToRouteResult)(actual))).RouteValues["action"].ToString(); Assert.IsTrue(actionName == "Index", "Regional Officer can not edit client data"); }
public async Task <ActionResult> Edit(ClientEditModel model) { if (!ModelState.IsValid) { return(PartialView("_Edit", model: model)); } var response = await _httpClientService.SendRequest("api/clients", HttpMethod.Put, model); if (response.IsSuccessStatusCode) { return(NotificationSuccessResult(Resource.RecordEditSuccess, Url.RouteUrl(ClientRoutes.Data))); } var errorMessage = await _commonService.CheckForValidationErrors(response, Resource.ApplicationErrorText); ModelState.AddModelError(string.Empty, errorMessage); return(PartialView("_Edit", model: model)); }
private int CreateOrUpdateClient(ClientEditModel clientEditModel, decimal hours) { int id = 0; if (clientEditModel.ClientId <= 0 || clientEditModel.ClientId == null) { var newClient = _mapper.Map <Client>(clientEditModel); newClient.Hours = hours; _context.Clients.Add(newClient); _context.SaveChanges(); id = newClient.ClientId; } else { var client = _context.Clients.Find(clientEditModel.ClientId); client.Hours += hours; _context.Clients.Update(client); _context.SaveChanges(); id = client.ClientId; } return(id); }
public UIElement GetAccountElement() { DataServiceMessage <ClientEditDTO> serviceMessage; using (IClientService service = factory.CreateClientService()) { serviceMessage = service.GetClientInfo(login); RaiseReceivedMessageEvent(serviceMessage); } UIElement element = null; if (serviceMessage.IsSuccessful) { ClientEditModel client = Mapper.Map <ClientEditDTO, ClientEditModel>(serviceMessage.Data); ClientInfoViewModel viewModel = GetClientInfoViewModel(client); ClientInfoControl control = new ClientInfoControl(viewModel); viewModel.ClientEdited += (s, e) => Edit(e.Client); element = control; } else { List <ServiceMessage> messages = new List <ServiceMessage>() { serviceMessage }; ErrorViewModel viewModel = new ErrorViewModel(messages); ErrorControl control = new ErrorControl(viewModel); element = control; } return(element); }
public void EditPost_Test() { Client cl = new ccEntities().Clients.Single(x => x.FirstName == "Client1"); ClientEditModel cm = new ClientEditModel(); cm.Data = cl; cl.City = "changed city"; ActionResult actual = Target.Edit(cl.Id); ViewResult actualView = (ViewResult)actual; Assert.IsNotNull(actual, "action result can not be null"); Assert.IsNotNull(actualView, "action result can not be null"); Assert.IsNotNull(actualView.Model, "action result can not be null"); ClientEditModel newModel = (ClientEditModel)actualView.Model; Assert.IsTrue(cm.Data.City == "changed city", "Client city must be changed"); }
protected override ClientInfoViewModel GetClientInfoViewModel(ClientEditModel clientEditModel) { return(new BookmakerClientInfoViewModel(clientEditModel)); }
public ActionResult ApplySP(ClientEditModel ce) { /* * Client newClient = new Client(ce); * * ClaimsIdentity identity = (ClaimsIdentity)User.Identity; * IEnumerable<Claim> claims = identity.Claims; * * newClient.CityId = Convert.ToInt16(claims.FirstOrDefault(c => c.Type == "CityId").Value); * newClient.DateCreated = DateTime.UtcNow.AddHours(8); * * db.Clients.Add(newClient); * * SoloParent newSC = new SoloParent(); * newSC.Status = "Pending"; * newSC.Client = newClient; * newSC.ApplicationDate = newClient.DateCreated; * * db.SoloParents.Add(newSC); * * if (ce.ClientBeneficiaries != null) * { * ce.ClientBeneficiaries.ForEach(c => c.ClientId = newClient.ClientId); * ce.ClientBeneficiaries.ForEach(c => db.ClientBeneficiary.Add(c)); * } * * string email = User.Identity.GetUserName(); * ApplicationUser au = db.Users.FirstOrDefault(u => u.UserName == email); * * au.ClientId = newClient.ClientId; * * List<Requirement> rl = new List<Requirement>{ * new Requirement { ClientId = newClient.ClientId, IsDone = false, Name = "Solo Parent Baranggay Certificate", Description = "Baranggay Certificate" }, * new Requirement { ClientId = newClient.ClientId, IsDone = false, Name = "Solo Parent Proof of Financial Status", Description = "Payslip, Bank Transactions" }, * new Requirement { ClientId = newClient.ClientId, IsDone = false, Name = "Solo Parent Supporting Document", Description = "Nullity of Marriage, Death Certificate" }, * new Requirement { ClientId = newClient.ClientId, IsDone = false, Name = "Solo Parent Birth Certificate (Children)", Description = "Birth Certificate of your child/children" }, * }; * * db.Requirements.AddRange(rl); * * if (db.SaveChanges() > 1) * { * return RedirectToAction("Requirements", "Clients", null); * } * else * { * return View(ce); * } */ string username = User.Identity.GetUserName(); ApplicationUser au = db.Users.FirstOrDefault(u => u.UserName == username); SoloParent newSC = new SoloParent(); if (au.Client != null) { // if existing client #region MODIFY CLIENT PROPERTIES au.Client.BirthDate = ce.BirthDate; au.Client.BirthPlace = ce.BirthPlace; au.Client.Citizenship = ce.Citizenship; au.Client.CityAddress = ce.CityAddress; au.Client.CivilStatus = ce.CivilStatus; au.Client.ContactNumber = ce.ContactNumber; au.Client.DateOfMarriage = ce.DateOfMarriage; au.Client.Gender = ce.Gender; au.Client.Occupation = ce.Occupation; au.Client.PlaceOfMarriage = ce.PlaceOfMarriage; au.Client.ProvincialAddress = ce.ProvincialAddress; au.Client.Religion = ce.Religion; au.Client.SpouseBirthDate = ce.SpouseBirthDate; au.Client.SpouseBluCardNo = ce.SpouseBluCardNo; au.Client.SpouseName = ce.SpouseName; au.Client.StartOfResidency = ce.StartOfResidency; au.Client.TypeOfResidency = ce.TypeOfResidency; #endregion // save modifications db.SaveChanges(); // add sc newSC.Status = "Pending"; newSC.Client = au.Client; newSC.ApplicationDate = au.Client.DateCreated; db.SoloParents.Add(newSC); // add beneficiaries if (ce.ClientBeneficiaries != null) { ce.ClientBeneficiaries.ForEach(c => c.ClientId = au.ClientId.Value); ce.ClientBeneficiaries.ForEach(c => db.ClientBeneficiary.Add(c)); } // add requirements List <Requirement> rl = new List <Requirement> { new Requirement { ClientId = au.Client.ClientId, IsDone = false, Name = "Solo Parent Baranggay Certificate", Description = "Baranggay Certificate" }, new Requirement { ClientId = au.Client.ClientId, IsDone = false, Name = "Solo Parent Proof of Financial Status", Description = "Payslip, Bank Transactions" }, new Requirement { ClientId = au.Client.ClientId, IsDone = false, Name = "Solo Parent Supporting Document", Description = "Nullity of Marriage, Death Certificate" }, new Requirement { ClientId = au.Client.ClientId, IsDone = false, Name = "Solo Parent Birth Certificate (Children)", Description = "Birth Certificate of your child/children" }, }; db.Requirements.AddRange(rl); // save if (db.SaveChanges() > 1) { return(RedirectToAction("Requirements", "Clients", null)); } else { return(View(ce)); } } else { // add client Client newClient = new Client(ce); ClaimsIdentity identity = (ClaimsIdentity)User.Identity; IEnumerable <Claim> claims = identity.Claims; newClient.CityId = Convert.ToInt16(claims.FirstOrDefault(c => c.Type == "CityId").Value); newClient.DateCreated = DateTime.UtcNow.AddHours(8); db.Clients.Add(newClient); // add sc newSC.Status = "Pending"; newSC.Client = newClient; newSC.ApplicationDate = newClient.DateCreated; db.SoloParents.Add(newSC); // add beneficiaries if (ce.ClientBeneficiaries != null) { ce.ClientBeneficiaries.ForEach(c => c.ClientId = newClient.ClientId); ce.ClientBeneficiaries.ForEach(c => db.ClientBeneficiary.Add(c)); } au.ClientId = newClient.ClientId; // add requirements List <Requirement> rl = new List <Requirement> { new Requirement { ClientId = newClient.ClientId, IsDone = false, Name = "Solo Parent Baranggay Certificate", Description = "Baranggay Certificate" }, new Requirement { ClientId = newClient.ClientId, IsDone = false, Name = "Solo Parent Proof of Financial Status", Description = "Payslip, Bank Transactions" }, new Requirement { ClientId = newClient.ClientId, IsDone = false, Name = "Solo Parent Supporting Document", Description = "Nullity of Marriage, Death Certificate" }, new Requirement { ClientId = newClient.ClientId, IsDone = false, Name = "Solo Parent Birth Certificate (Children)", Description = "Birth Certificate of your child/children" } }; db.Requirements.AddRange(rl); // save if (db.SaveChanges() > 1) { return(RedirectToAction("Requirements", "Clients", null)); } else { return(View(ce)); } } }
public ClientEditEventArgs(ClientEditModel client) { this.Client = client; }
public BookmakerClientInfoViewModel(ClientEditModel client) : base(client) { }
// GET: SeniorCitizens/Create public ActionResult Create() { ClientEditModel ce = new ClientEditModel(); return(View(ce)); }
public ClientClientInfoViewModel(ClientEditModel client) : base(client) { }
protected override ClientInfoViewModel GetClientInfoViewModel(ClientEditModel client) { return(new ClientClientInfoViewModel(client)); }
protected abstract ClientInfoViewModel GetClientInfoViewModel(ClientEditModel client);
public ActionResult ApplySC(ClientEditModel ce) { string username = User.Identity.GetUserName(); ApplicationUser au = db.Users.FirstOrDefault(u => u.UserName == username); SeniorCitizen newSC = new SeniorCitizen(); if (au.Client != null) { // if existing client #region MODIFY CLIENT PROPERTIES au.Client.BirthDate = ce.BirthDate; au.Client.BirthPlace = ce.BirthPlace; au.Client.Citizenship = ce.Citizenship; au.Client.CityAddress = ce.CityAddress; au.Client.CivilStatus = ce.CivilStatus; au.Client.ContactNumber = ce.ContactNumber; au.Client.DateOfMarriage = ce.DateOfMarriage; au.Client.Gender = ce.Gender; au.Client.Occupation = ce.Occupation; au.Client.PlaceOfMarriage = ce.PlaceOfMarriage; au.Client.ProvincialAddress = ce.ProvincialAddress; au.Client.Religion = ce.Religion; au.Client.SpouseBirthDate = ce.SpouseBirthDate; au.Client.SpouseBluCardNo = ce.SpouseBluCardNo; au.Client.SpouseName = ce.SpouseName; au.Client.StartOfResidency = ce.StartOfResidency; au.Client.TypeOfResidency = ce.TypeOfResidency; #endregion // save modifications db.SaveChanges(); // add sc newSC.Status = "Pending"; newSC.Client = au.Client; newSC.ApplicationDate = au.Client.DateCreated; db.SeniorCitizens.Add(newSC); // add beneficiaries if (ce.ClientBeneficiaries != null) { ce.ClientBeneficiaries.ForEach(c => c.ClientId = au.ClientId.Value); ce.ClientBeneficiaries.ForEach(c => db.ClientBeneficiary.Add(c)); } // add requirements List <Requirement> rl = new List <Requirement> { new Requirement { ClientId = au.ClientId.Value, IsDone = false, Name = "Senior Citizen Recent Photo", Description = "Upload a recent picture of yourself" }, new Requirement { ClientId = au.ClientId.Value, IsDone = false, Name = "Senior Citizen Supporting Document", Description = "Any of the following; Driver's License, Voter’s ID, NBI Clearance, Old Residence Certificate, Police Clearance" }, }; db.Requirements.AddRange(rl); // save if (db.SaveChanges() > 1) { return(RedirectToAction("Requirements", "Clients", null)); } else { return(View(ce)); } } else { // add client Client newClient = new Client(ce); ClaimsIdentity identity = (ClaimsIdentity)User.Identity; IEnumerable <Claim> claims = identity.Claims; newClient.CityId = Convert.ToInt16(claims.FirstOrDefault(c => c.Type == "CityId").Value); newClient.DateCreated = DateTime.UtcNow.AddHours(8); db.Clients.Add(newClient); // add sc newSC.Status = "Pending"; newSC.Client = newClient; newSC.ApplicationDate = newClient.DateCreated; db.SeniorCitizens.Add(newSC); // add beneficiaries if (ce.ClientBeneficiaries != null) { ce.ClientBeneficiaries.ForEach(c => c.ClientId = newClient.ClientId); ce.ClientBeneficiaries.ForEach(c => db.ClientBeneficiary.Add(c)); } au.ClientId = newClient.ClientId; // add requirements List <Requirement> rl = new List <Requirement> { new Requirement { ClientId = newClient.ClientId, IsDone = false, Name = "Senior Citizen Recent Photo", Description = "Upload a recent picture of yourself" }, new Requirement { ClientId = newClient.ClientId, IsDone = false, Name = "Senior Citizen Supporting Document", Description = "Any of the following; Driver's License, Voter’s ID, NBI Clearance, Old Residence Certificate, Police Clearance" }, }; db.Requirements.AddRange(rl); // save if (db.SaveChanges() > 1) { return(RedirectToAction("Requirements", "Clients", null)); } else { return(View(ce)); } } }