public IHttpActionResult Post([FromBody] PatientEntryModel model) { try { if (ModelState.IsValid) { var entity = new Patient { Account = new Account { Username = model.Username, Password = model.Password, Email = model.Email, CreationDate = DateTime.Now }, FirstName = model.FirstName, LastName = model.LastName, BirthDate = model.BirthDate.Value, Status = model.Status, Gender = model.Gender, Telephone = model.Telephone, Address = model.Address, MedicareNumber = model.MedicareNumber }; _repository.Add(entity); _repository.Commit(); model.AccountId = entity.AccountId; return(base.Ok(model)); } else { return(base.BadRequest(ModelState)); } } catch (Exception ex) { return(base.BadRequest(ex.Message)); } }