public IActionResult Freelancer(FreeLancerViewModel Lancer) { if (Lancer is null) { throw new ArgumentNullException(nameof(Lancer)); } if (!ModelState.IsValid) { return(View()); } _db.FreeLancers.Add(Lancer); _db.SaveChanges(); return(View()); }
public IActionResult getFreeLancersWithStories() { var freelancers = freeLancerRepository.GetForStories(); List <FreeLancerViewModel> freelancersVm = new List <FreeLancerViewModel>(); foreach (var freelancer in freelancers) { FreeLancerViewModel freeLancerViewModel = new FreeLancerViewModel(); var user = userRepository.GetById(freelancer.User_Id); freeLancerViewModel.Id = freelancer.Id; freeLancerViewModel.JobTitle = freelancer.JobTitle; freeLancerViewModel.Name = freelancer.Name; freeLancerViewModel.Brief = freelancer.Brief; freeLancerViewModel.Image = user.ImageUrl; freelancersVm.Add(freeLancerViewModel); } return(Ok(freelancersVm)); }