public async Task <IActionResult> Create(CreateRecordView model) { var psychologist = Request.Form["psychologistSelect"]; if (psychologist == StringValues.Empty) { ViewBag.Message = "No psychologist for now please try later or write us on [email protected]"; return(View("ErrorPage")); } var record = new Record { CustomerId = unitOfWork.Customers.GetAll().First(c => c.Email == User.Identity.Name) .CustomerId, Psychologist = unitOfWork.Psychologists.GetAll().First(p => p.Surname == psychologist), InitialDate = DateTime.Now, AssignedDate = model.AssignedDate, ATime = model.ATime }; await unitOfWork.Records.Create(record); await unitOfWork.SaveAsync(); return(RedirectToAction("Index", "User")); }
public IActionResult Create() { var model = new CreateRecordView { Psychologists = unitOfWork.Psychologists.GetAll().ToList() }; return(View(model)); }