public async Task <IActionResult> PinService(int organizationId, int serviceId) { Organization organization = dbContext.Organization.FirstOrDefault(t => t.ID == organizationId); Service service = dbContext.Service.FirstOrDefault(t => t.ID == serviceId); if (organization == null || service == null) { return(NotFound()); } OrganizationServiceRelation organizationServiceRelation = new OrganizationServiceRelation() { Organization_ID = organization, Service_ID = service, Price = service.Price, Duration = service.Duration }; ApplicationUser user = await _userManager.FindByNameAsync(_userManager.GetUserId(User)); if (organization.User == user) { dbContext.OrganizationServiceRelation.Add(organizationServiceRelation); dbContext.SaveChanges(); return(new ObjectResult(organizationServiceRelation)); } return(BadRequest()); }
public IActionResult PinService(int organizationId, int serviceId) { Organization organization = dbContext.Organization.FirstOrDefault(t => t.ID == organizationId); Service service = dbContext.Service.FirstOrDefault(t => t.ID == serviceId); if (organization == null || service == null) { return(NotFound()); } OrganizationServiceRelation organizationServiceRelation = new OrganizationServiceRelation() { Organization_ID = organization, Service_ID = service, Price = service.Price, Duration = service.Duration }; dbContext.OrganizationServiceRelation.Add(organizationServiceRelation); dbContext.SaveChanges(); return(new ObjectResult(organizationServiceRelation)); }