public override IHttpActionResult Post(HddInfo model) { if (!ModelState.IsValid) { return(BadRequest()); } var lastCreatedCaseCode = _service.LastCreatedCaseCode(); if (string.IsNullOrWhiteSpace(lastCreatedCaseCode)) { return(BadRequest()); } model.CaseNo = HelperRequestModel.GetCaseNo((Convert.ToInt32(lastCreatedCaseCode) + 1).ToString()); model.Created = DateTime.Now; model.CreatedBy = User.Identity.GetUserId(); model.Modified = DateTime.Now; var add = _service.Add(model); if (!add) { return(BadRequest()); } AddCaseLog(model); return(Ok(model.Id)); }
public IActionResult Add(CaseViewModel caseViewModel) { var newcase = new Cases(); if (ModelState.IsValid) { newcase.NameSurname = caseViewModel.NameSurname; newcase.Age = caseViewModel.Age; newcase.Sex = caseViewModel.Sex; newcase.City = caseViewModel.City; newcase.FirstSymptoms = caseViewModel.FirstSymptoms; newcase.FirstSyptomsDate = caseViewModel.FirstSyptomsDate; newcase.FirstTestDate = caseViewModel.FirstTestDate; newcase.ResultFirstTest = caseViewModel.ResultFirstTest; newcase.Condition = caseViewModel.Condition; newcase.Recover = caseViewModel.Recover; newcase.Death = caseViewModel.Death; _caseService.Add(newcase); return(RedirectToAction(nameof(Index))); } return(View(newcase)); }