public async Task <IHttpActionResult> PostService(CreateRentVehicleServiceBindingModel model) { HttpRequest httpRequest = HttpContext.Current.Request; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!ImageHelper.ValidateImage(httpRequest.Files[0], out validationErrorMessage)) { return(BadRequest(validationErrorMessage)); } RAIdentityUser user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); if (UserManager.IsInRole(user.Id, "Manager")) { if (unitOfWork.BanedManagers.Find(bm => bm.User.Id == user.Id).Count() > 0) { return(BadRequest("You are baned for add service.")); } } Service service = new Service() { Creator = user.Id, Name = model.Name, EmailAddress = model.ContactEmail, Description = model.Description, LogoImage = ImageHelper.SaveImageToServer(httpRequest.Files[0]), IsApproved = false }; try { lock (lockObjectForServices) { unitOfWork.Services.Add(service); unitOfWork.Complete(); } } catch (DBConcurrencyException) { return(NotFound()); } NotificationHub.NewRentVehicleServiceToApprove(unitOfWork.Services.Find(s => !s.IsApproved).Count()); return(Ok("RentVehicle Service succsessfully created")); }