public async Task <IActionResult> Edit(SocioEditInputModel inputModel) { if (ModelState.IsValid) { SocioDetailViewModel socio = await soci.EditSocioAsync(inputModel); TempData["ConfirmationMessage"] = "I dati sono stati aggiornati con successo"; return(RedirectToAction(nameof(Detail), new { id = inputModel.Id })); } ViewData["Title"] = applicationPersister.GetTitoloApp(); return(View(inputModel)); }
public async Task <SocioDetailViewModel> GetSocioAsync(int id) { IQueryable <SocioDetailViewModel> queryLinq = dbContext.Soci .AsNoTracking() .Include(socio => socio.SociFamiliari) .Include(socio => socio.SociRinnovi) .Where(socio => socio.Id == id) .Select(socio => socio.ToSocioDetailViewModel()); SocioDetailViewModel viewModel = await queryLinq.FirstOrDefaultAsync(); if (viewModel == null) { logger.LogWarning("Socio {id} non trovato", id); throw new SocioNotFoundException(id); } return(viewModel); }
public async Task <IActionResult> Detail(int id) { ViewData["Title"] = applicationPersister.GetTitoloApp(); bool StatusSocio = await soci.IsSocioRegolareAsync(id); if (StatusSocio == true) { ViewData["StatoSocio"] = "In regola"; } else { ViewData["StatoSocio"] = "Non in regola"; } SocioDetailViewModel viewModel = await soci.GetSocioAsync(id); return(View(viewModel)); }
public async Task <IActionResult> Create(SocioCreateInputModel inputModel) { if (ModelState.IsValid) { try { SocioDetailViewModel socio = await soci.CreateSocioAsync(inputModel); TempData["ConfirmationMessage"] = "Il socio è stato creato con successo"; return(RedirectToAction(nameof(Detail), new { id = socio.Id })); } catch (SocioUnavailableException) { ModelState.AddModelError(nameof(SocioDetailViewModel.Nominativo), "Il nominativo del socio esiste già"); } } ViewData["Title"] = applicationPersister.GetTitoloApp(); return(View(inputModel)); }