public HttpResponseMessage Post(CreateTermDefinitionRequest request) { return(Request.CreateResponse(HttpStatusCode.OK, _service.CreateTermDefinition(User, request))); }
public virtual CreateTermDefinitionResponse CreateTermDefinition(IPrincipal principal, CreateTermDefinitionRequest request) { var user = _dependencies.UserService.GetGuaranteedAuthenticatedUser(principal); var organisation = _dependencies.OrganisationService.GetOrganisation(request.OrganisationId); _dependencies.OrganisationService.GuaranteeUserHasPermission(user, organisation, ShurahOrganisationPermission.EditMembershipRules); if (organisation.Terms.Any(t => t.Term == request.Term)) { return(new CreateTermDefinitionResponse { HasError = true, Error = "This term already exists" }); } var defn = new MembershipRuleTermDefinition(); defn.Term = request.Term; defn.Definition = request.Definition; defn.Organisation = organisation; defn.OrganisationId = request.OrganisationId; _dependencies.StorageService.SetOf <MembershipRuleTermDefinition>().Add(defn); _dependencies.StorageService.SaveChanges(); return(new CreateTermDefinitionResponse { Id = defn.Id, Term = defn.Term }); }
public CreateTermDefinitionResponse Post(CreateTermDefinitionRequest request) { return(_service.CreateTermDefinition(User, request)); }