public HttpResponseMessage Post(DegreeApiModel model) { if (model == null) return Request.CreateResponse(HttpStatusCode.BadRequest); var command = new CreateDegree(User); Mapper.Map(model, command); _createHandler.Handle(command); var response = Request.CreateResponse(HttpStatusCode.Created, "Degree was successfully created."); var url = Url.Link(null, new { controller = "MyDegrees", action = "Get", degreeId = command.CreatedDegreeId, }); Debug.Assert(url != null); response.Headers.Location = new Uri(url); return response; }
public HttpResponseMessage Post(DegreeApiModel newModel) { if ( (newModel == null) || (newModel.Title == null) ) { return Request.CreateResponse(HttpStatusCode.InternalServerError); } var createDeepDegreeCommand = new CreateDegree(User, newModel.Title) { YearAwarded = newModel.YearAwarded, InstitutionId = newModel.InstitutionId }; _createDegree.Handle(createDeepDegreeCommand); var id = createDeepDegreeCommand.CreatedDegree.RevisionId; return Request.CreateResponse(HttpStatusCode.OK, id); }
public void Seed() { /* ----- USF People Degrees ----- */ { // Douglas Corarito Person person = _entities.Get <Person>().SingleOrDefault(x => x.FirstName == "Douglas" && x.LastName == "Corarito"); if (person == null) { throw new Exception("USF person Douglas Corarito not found"); } User user = _entities.Get <User>().SingleOrDefault(x => x.Person.RevisionId == person.RevisionId); if (user == null) { throw new Exception("USF person Douglas Corarito has no User."); } var developerRoles = new[] { RoleName.AuthorizationAgent, RoleName.EstablishmentLocationAgent, RoleName.EstablishmentAdministrator, RoleName.ElmahViewer, RoleName.AgreementManager, RoleName.AgreementSupervisor, RoleName.EmployeeProfileManager, }; var identity = new GenericIdentity(user.Name); var principal = new GenericPrincipal(identity, developerRoles); CreateDegree createDegreeCommand; Establishment institution; string institutionName; // DEGREE 1 var entityId = new Guid("89538B2C-D4E9-4ABD-940D-16A7E08741A1"); bool degreeExists = _entities.Get <Degree>().Count(x => x.EntityId == entityId) > 0; if (!degreeExists) { institutionName = "University of Florida"; institution = _entities.Get <Establishment>().FirstOrDefault(x => x.OfficialName == institutionName); if (institution == null) { string message = String.Format("{0} not found", institutionName); throw new Exception(message); } createDegreeCommand = new CreateDegree(principal) { Title = "Master of Science", EntityId = entityId, FieldOfStudy = "Molecular Biology", YearAwarded = 2005, InstitutionId = institution.RevisionId }; _createDegree.Handle(createDegreeCommand); _unitOfWork.SaveChanges(); } // DEGREE 1 // DEGREE2 entityId = new Guid("38B78A49-B376-4851-BFF3-B44FE27800DA"); degreeExists = _entities.Get <Degree>().Count(x => x.EntityId == entityId) > 0; if (!degreeExists) { institutionName = "University of Florida"; institution = _entities.Get <Establishment>().FirstOrDefault(x => x.OfficialName == institutionName); if (institution == null) { string message = String.Format("{0} not found", institutionName); throw new Exception(message); } createDegreeCommand = new CreateDegree(principal) { Title = "Bachelor of Arts", EntityId = entityId, YearAwarded = 1994, InstitutionId = institution.RevisionId }; _createDegree.Handle(createDegreeCommand); _unitOfWork.SaveChanges(); } // DEGREE 1 } // Douglas Corarito }
public void Seed() { /* ----- USF People Degrees ----- */ { // Douglas Corarito Person person = _entities.Get<Person>().SingleOrDefault(x => x.FirstName == "Douglas" && x.LastName == "Corarito"); if (person == null) throw new Exception("USF person Douglas Corarito not found"); User user = _entities.Get<User>().SingleOrDefault(x => x.Person.RevisionId == person.RevisionId); if (user == null) throw new Exception("USF person Douglas Corarito has no User."); var developerRoles = new[] { RoleName.AuthorizationAgent, RoleName.EstablishmentLocationAgent, RoleName.EstablishmentAdministrator, RoleName.ElmahViewer, RoleName.AgreementManager, RoleName.AgreementSupervisor, RoleName.EmployeeProfileManager, }; var identity = new GenericIdentity(user.Name); var principal = new GenericPrincipal(identity, developerRoles); CreateDegree createDegreeCommand; Establishment institution; string institutionName; // DEGREE 1 var entityId = new Guid("89538B2C-D4E9-4ABD-940D-16A7E08741A1"); bool degreeExists = _entities.Get<Degree>().Count(x => x.EntityId == entityId) > 0; if (!degreeExists) { institutionName = "University of Florida"; institution = _entities.Get<Establishment>().FirstOrDefault(x => x.OfficialName == institutionName); if (institution == null) { string message = String.Format("{0} not found", institutionName); throw new Exception(message); } createDegreeCommand = new CreateDegree(principal) { Title = "Master of Science", EntityId = entityId, FieldOfStudy = "Molecular Biology", YearAwarded = 2005, InstitutionId = institution.RevisionId }; _createDegree.Handle(createDegreeCommand); _unitOfWork.SaveChanges(); } // DEGREE 1 // DEGREE2 entityId = new Guid("38B78A49-B376-4851-BFF3-B44FE27800DA"); degreeExists = _entities.Get<Degree>().Count(x => x.EntityId == entityId) > 0; if (!degreeExists) { institutionName = "University of Florida"; institution = _entities.Get<Establishment>().FirstOrDefault(x => x.OfficialName == institutionName); if (institution == null) { string message = String.Format("{0} not found", institutionName); throw new Exception(message); } createDegreeCommand = new CreateDegree(principal) { Title = "Bachelor of Arts", EntityId = entityId, YearAwarded = 1994, InstitutionId = institution.RevisionId }; _createDegree.Handle(createDegreeCommand); _unitOfWork.SaveChanges(); } // DEGREE 1 } // Douglas Corarito }