private static CovidRegistrationModel MapToModel(CovidRegistrationViewModel viewModel) => new CovidRegistrationModel { Id = viewModel.Id, Cpr = viewModel.Cpr, Name = viewModel.Name, RegistrationDate = viewModel.RegistrationDate, Result = viewModel.Result };
public async Task <ActionResult> EditAsync([Bind("Id", "Cpr", "Name", "RegistrationDate", "Result")] CovidRegistrationViewModel viewModel) { if (ModelState.IsValid) { var model = MapToModel(viewModel); await _cosmosDbService.UpdateItemAsync(model.Id, model); return(RedirectToAction("Index")); } return(View(viewModel)); }
public async Task <ActionResult> CreateAsync([Bind("Cpr", "Name", "RegistrationDate", "Result")] CovidRegistrationViewModel viewModel) { if (ModelState.IsValid) { var model = MapToModel(viewModel); model.Id = Guid.NewGuid().ToString(); await _cosmosDbService.AddItemAsync(model.Id, model); return(RedirectToAction("Index")); } return(View(viewModel)); }