private async Task <Consultant> CreateConsultantAsync(ConsultantModel model) { IFormFile formFile = Request.Form.Files.FirstOrDefault(); var consultant = new Consultant { Name = model.FullName, DateOfBirth = DateTime.Parse(model.DateOfBirth), EmailAddress = model.EmailAddress, StreetAddress = model.StreetAddress, ZipCode = int.Parse(model.ZipCode), City = model.City, IsOnAssignment = model.IsOnAssignment, Skills = model.Skills, }; if (model.ConsultantId.HasValue) { consultant.ConsultantId = model.ConsultantId.Value; } if (formFile != null) { consultant.ConsultantImage = new ConsultantImage { Data = await formFile.GetBufferAsync(), Name = formFile.Name }; } return(consultant); }