public ActionResult Save(CitizenViewModel viewModel) { if (!ModelState.IsValid) { var invalidViewModel = new CitizenViewModel { Citizen = viewModel.Citizen, Zones = db.Zones.ToList() }; return(View("CitizenForm", invalidViewModel)); } if (viewModel.Citizen.CitizenId == 0) { db.Citizens.Add(viewModel.Citizen); } else { var citizenInDB = db.Citizens.Single(c => c.CitizenId == viewModel.Citizen.CitizenId); citizenInDB.FirstName = viewModel.Citizen.FirstName; citizenInDB.LastName = viewModel.Citizen.LastName; citizenInDB.StreetName = viewModel.Citizen.StreetName; citizenInDB.District = viewModel.Citizen.District; citizenInDB.ZoneId = viewModel.Citizen.ZoneId; citizenInDB.Wardno = viewModel.Citizen.Wardno; citizenInDB.CitizenshipNo = viewModel.Citizen.CitizenshipNo; citizenInDB.Municipality = viewModel.Citizen.Municipality; } db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public ActionResult ProcessCitizenProfile(CitizenViewModel citizenViewModel) { var citizen = new Citizen(); citizen.AadharNumber = citizenViewModel.AadharNumber; citizen.ApplicationId = citizenViewModel.ApplicationNumber; citizen.SurveyorName = citizenViewModel.SurveyorName; citizen.VehicleType = (int)citizenViewModel.VehicleType; citizen.Venue = citizenViewModel.Venue; citizen.ReportingDate = DateTime.Parse(citizenViewModel.ReportingDate).Date; DateTime dt; if (!DateTime.TryParseExact(citizenViewModel.ReportingTime, "HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt)) { // handle validation error } citizen.ReportingTime = dt.TimeOfDay; var rtaBll = new ASTIRTA(); rtaBll.ProcessCitizenProfile(citizen); return(View(citizenViewModel)); }
public ActionResult Edit(int?citizenID) { if (citizenID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var citizens = db.Citizens.ToList(); var citizen = db.Citizens.Find(citizenID); if (citizen == null) { return(HttpNotFound()); } var viewModel = new CitizenViewModel { Citizen = citizen, Zones = db.Zones.ToList() }; ViewBag.title = "Edit"; return(View("CitizenForm", viewModel)); }
public ActionResult ScheduleLicenseApplication(LicenseViewModel licenseModel) { var selectedAadharNumber = licenseModel.SelectedId; var citizenModel = new CitizenViewModel(); var rta = new ASTIRTA(); var pendingCitizen = rta.GetLicensePendingCitizen(selectedAadharNumber); citizenModel.Name = pendingCitizen.Name; citizenModel.Address = pendingCitizen.Address; citizenModel.Contact = pendingCitizen.Contact; citizenModel.DateOfBirth = pendingCitizen.DateOfBirth; citizenModel.FatherName = pendingCitizen.FatherName; citizenModel.Gender = pendingCitizen.Gender; citizenModel.Occupation = pendingCitizen.Occupation; citizenModel.ImagePath = pendingCitizen.ImagePath; citizenModel.PinCode = pendingCitizen.PinCode; citizenModel.SurveyorName = pendingCitizen.SurveyorName; citizenModel.ApplicationNumber = pendingCitizen.ApplicationId; citizenModel.DateOfRegistration = DateTime.Now;//Should be recieved from DB citizenModel.IsPending = pendingCitizen.IsPending; citizenModel.IsLicensePending = pendingCitizen.IsLicensePending; citizenModel.AadharNumber = pendingCitizen.AadharNumber; return(View("CitizenProfile", citizenModel)); }
public List <Citizen> GetCitizenList(CitizenViewModel model) { List <Citizen> citizenList = new List <Citizen>(); using (conn = new DB2Connection(connectionString)) { conn.Open(); using (DB2Command cmd = conn.CreateCommand()) { cmd.CommandText = CitizenHelper.CitizenSearchQueryBuilder(model); rd = cmd.ExecuteReader(); rd.Read(); do { if (rd.HasRows) { Citizen citizen = new Citizen { Id = int.Parse(rd[0].ToString()), Surname = rd[1].ToString().Trim(' '), CitizenName = rd[2].ToString().Trim(' '), Middlename = rd[3].ToString().Trim(' '), BirthDate = DateTime.Parse(rd[4].ToString()) }; citizenList.Add(citizen); } } while (rd.Read()); } } return(citizenList); }
public static string CitizenSearchQueryBuilder(CitizenViewModel model) { string selectCommnand = "select * from citizen where "; int andCounter = 0; if (model.Name != null) { if (model.Name.Contains("*")) { selectCommnand += $"citizenname LIKE '{model.Name.Replace("*", "%")}' and "; } else { selectCommnand += $"citizenname = '{model.Name}' and "; } andCounter++; } if (model.Surname != null) { if (model.Surname.Contains("*")) { selectCommnand += $"surname LIKE '{model.Surname.Replace("*", "%")}' and "; } else { selectCommnand += $"surname = '{model.Surname}' and "; } andCounter++; } if (model.Middlename != null) { if (model.Middlename.Contains("*")) { selectCommnand += $"middlename LIKE '{model.Middlename.Replace("*", "%")}' and "; } else { selectCommnand += $"middlename = '{model.Middlename}' and "; } andCounter++; } if (model.BeginBirthDate != null) { selectCommnand += $"birthdate >= '{model.BeginBirthDate?.ToShortDateString()}' and "; andCounter++; } if (model.EndBirthDate != null) { selectCommnand += $"birthdate <= '{model.EndBirthDate?.ToShortDateString()}' "; andCounter++; } if (andCounter != 5) { selectCommnand = selectCommnand.Substring(0, selectCommnand.Length - 4); } return(selectCommnand); }
public IActionResult Edit(CitizenViewModel citizenViewModel) { if (!ModelState.IsValid) { return(View(citizenViewModel)); } _citizenAppService.Update(citizenViewModel); return(RedirectToAction("Index")); }
public ActionResult AllocateUID(CitizenViewModel citizenModel) { var admin = new ASTIAdmin(); //Right now not clear about what allocate uid is supposed to do, just making IsPending as false admin.AllocateUserId(citizenModel.ApplicationNumber); ViewBag.IsUIDAllocated = true; return(View("UIDAllocation")); }
public ActionResult New() { var zones = db.Zones.ToList(); var viewModel = new CitizenViewModel { Zones = zones, Citizen = new Citizen() }; ViewBag.title = "New"; return(View("CitizenForm", viewModel)); }
public ActionResult ProcessCitizen(CitizenViewModel citizenModel) { if (citizenModel.SelectedProcess == "Accept") { var admin = new ASTIAdmin(); var citizen = new Citizen(); citizen = admin.GetAadharInformation(citizenModel.ApplicationNumber); citizenModel.AadharNumber = citizen.AadharNumber; citizenModel.AadharPassword = citizen.AadharPassword; return(View("UIDAllocation", citizenModel)); } else { return(View("Rejected")); } }
public ActionResult ProcessPendingApplication(ApplicationViewModel appModel) { var selectedApplicationNumber = appModel.SelectedApplicationId; var citizenModel = new CitizenViewModel(); var admin = new ASTIAdmin(); var pendingCitizen = admin.GetPendingCitizen(selectedApplicationNumber); citizenModel.Name = pendingCitizen.Name; citizenModel.Address = pendingCitizen.Address; citizenModel.Contact = pendingCitizen.Contact; citizenModel.DateOfBirth = pendingCitizen.DateOfBirth; citizenModel.FatherName = pendingCitizen.FatherName; citizenModel.Gender = pendingCitizen.Gender; citizenModel.Occupation = pendingCitizen.Occupation; citizenModel.ImagePath = pendingCitizen.ImagePath; citizenModel.PinCode = pendingCitizen.PinCode; citizenModel.SurveyorName = pendingCitizen.SurveyorName; //Should be recieved from DB citizenModel.ApplicationNumber = selectedApplicationNumber; citizenModel.DateOfRegistration = pendingCitizen.DateOfRegistration; //Should be recieved from DB citizenModel.IsPending = pendingCitizen.IsPending; return(View("ProcessCitizen", citizenModel)); }
public ActionResult Details(int?citizenID) { if (citizenID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var citizens = db.Citizens.ToList(); Citizen citizen = db.Citizens.Find(citizenID); if (citizen == null) { return(HttpNotFound()); } var viewModel = new CitizenViewModel { Citizen = citizen, Zones = db.Zones.ToList() }; //return View(citizen); return(View(viewModel)); }
public ActionResult Search(CitizenViewModel model) { List <Citizen> data = repo.GetCitizenList(model); return(this.Store(data)); }
public void Update(CitizenViewModel citizenViewModel) { var updateCitizenCommand = _mapper.Map <UpdateCitizenCommand>(citizenViewModel); _bus.SendCommand(updateCitizenCommand); }
public void Add(CitizenViewModel citizenViewModel) { var registerCitizenCommand = _mapper.Map <RegisterCitizenCommand>(citizenViewModel); _bus.SendCommand(registerCitizenCommand); }
public async Task <IActionResult> OnPostChangeEmailAsync() { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Não foi possível carregar o usuário com o ID '{_userManager.GetUserId(User)}'.")); } if (!ModelState.IsValid) { await LoadAsync(user); return(Page()); } var citizen = new CitizenViewModel { Id = Guid.Parse(user.Id), Name = Input.Name, NickName = Input.NickName, Document = Input.Document, Email = Input.NewEmail, Gender = Input.Gender }; _citizenAppService.Update(citizen); if (!IsValidOperation()) { return(ErrorUpdate()); } var email = await _userManager.GetEmailAsync(user); if (Input.NewEmail != email) { //var userId = await _userManager.GetUserIdAsync(user); //var code = await _userManager.GenerateChangeEmailTokenAsync(user, Input.NewEmail); //var callbackUrl = Url.Page( // "/Account/ConfirmEmailChange", // pageHandler: null, // values: new { userId = userId, email = Input.NewEmail, code = code }, // protocol: Request.Scheme); //await _emailSender.SendEmailAsync( // Input.NewEmail, // "Confirm your email", // $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); user.Email = Input.NewEmail; user.UserName = Input.NewEmail; var result = await _userManager.UpdateAsync(user); if (!result.Succeeded) { return(ErrorUpdate()); } // StatusMessage = "Confirmation link to change email sent. Please check your email."; StatusMessage = "Dados Atualizados com sucesso!"; return(RedirectToPage()); } StatusMessage = "Dados Atualizados com sucesso!"; return(RedirectToPage()); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (ModelState.IsValid) { var user = new ApplicationUser { UserName = Input.Email, Email = Input.Email, Active = true }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { _logger.LogInformation("O usuário criou uma nova conta com senha."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { area = "Identity", userId = user.Id, code = code }, protocol: Request.Scheme); var citizen = new CitizenViewModel { Id = Guid.Parse(user.Id), Name = Input.Name, NickName = Input.NickName, Document = Input.Document, Email = user.Email, Gender = Input.Gender }; _citizenAppService.Add(citizen); if (!IsValidOperation()) { await _userManager.DeleteAsync(user); return(Page()); } await _emailSender.SendEmailAsync(Input.Email, "Confirme seu email", $"Por favor, confirme sua conta <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clique aqui</a>."); if (_userManager.Options.SignIn.RequireConfirmedAccount) { return(RedirectToPage("RegisterConfirmation", new { email = Input.Email })); } else { await _signInManager.SignInAsync(user, isPersistent : false); return(LocalRedirect(returnUrl)); } } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }