public IHttpActionResult PostService(ServiceFront service) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var user = UserManager.Users.FirstOrDefault(u => u.Id == service.UserName); Service zaUpis = new Service(); zaUpis.AppUserId = user.AppUserId; zaUpis.Description = service.Description; zaUpis.Email = service.Email; zaUpis.Name = service.Name; List <Service> sviServisi = (List <Service>)unitOfWork.Services.GetAll(); foreach (var sc in sviServisi) { if (sc.Name == zaUpis.Name) { return(Conflict()); } } unitOfWork.Services.Add(zaUpis); unitOfWork.Complete(); return(Ok()); }
public IHttpActionResult PutService(ServiceFront service) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Service s1 = new Service(); List <Service> listaServisa = (List <Service>)unitOfWork.Services.GetAll(); foreach (var sc in listaServisa) { if (sc.Name == service.Name) { s1 = sc; break; } } unitOfWork.Services.ApproveService(s1.Id); unitOfWork.Complete(); return(Ok()); }