private async Task MakeFreelance(Provider provider, FreelanceBindingModel model, DateTime startDate) { var newFreelance = Mapper.Map <Freelance>(model); newFreelance.StartDate = startDate; FreelanceCalendarService.Insert(provider.Freelances.ToList(), newFreelance); provider.Freelances.Add(newFreelance); await _providerRepo.SaveAsUserAsync(UserId); }
public async Task <IHttpActionResult> PostFreelance(int id, [FromBody] FreelanceBindingModel model) { var provider = await _providerRepo.FindByIdAsync(id); if (provider == null) { return(BadRequest("provider not found")); } await MakeFreelance(provider, model, DateTime.Today); return(Ok()); }