public void DeleteShouldDeleteTheaterJob()
        {
            var dbcontext         = new BroadwayBuilderContext();
            var theaterService    = new TheaterService(dbcontext);
            var theaterJobService = new TheaterJobService(dbcontext);
            //var expected = true;
            //var actual = false;

            var theater = new Theater("someTheater", "Regal", "theater st", "LA", "CA", "US", "323323");

            theaterService.CreateTheater(theater);
            dbcontext.SaveChanges();
            var jobPosting = new TheaterJobPosting(theater.TheaterID, "intern", "some decription", "title", "hours", "some requirements", "testType");

            theaterJobService.CreateTheaterJob(jobPosting);
            dbcontext.SaveChanges();
            var controller = new HelpWantedController();

            //Act
            var actionResult = controller.DeleteTheaterJob(jobPosting.HelpWantedID);
            var response     = actionResult as NegotiatedContentResult <string>;
            var content      = response.Content;

            var dbcontext2      = new BroadwayBuilderContext();
            var theaterService2 = new TheaterService(dbcontext2);

            theaterService2.DeleteTheater(theater);
            dbcontext2.SaveChanges();
            //Assert
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Content);
            Assert.AreEqual("Successfully Deleted Job Posting", content);
            Assert.AreEqual((HttpStatusCode)202, response.StatusCode);
        }
        public void TheaterJobService_ReadTheaterJobPosting_Pass()
        {
            //Arrange
            var dbcontext         = new BroadwayBuilderContext();
            var theaterService    = new TheaterService(dbcontext);
            var theaterJobService = new TheaterJobService(dbcontext);
            var expected          = true;
            var actual            = false;

            var theater = new Theater("someTheater", "Regal", "theater st", "LA", "CA", "US", "323323");

            var jobPosting = new TheaterJobPosting(theater.TheaterID, "intern", "some decription", "title", "hours", "some requirements", "testType");

            //Act
            theaterService.CreateTheater(theater);
            theaterJobService.CreateTheaterJob(jobPosting);
            dbcontext.SaveChanges();
            TheaterJobPosting getTheaterJob = theaterJobService.GetTheaterJob(jobPosting);

            if (getTheaterJob != null)
            {
                actual = true;
            }
            theaterJobService.DeleteTheaterJob(jobPosting);
            dbcontext.SaveChanges();
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void PostShouldAddTheaterJob()//need to update
        {
            var dbcontext      = new BroadwayBuilderContext();
            var theaterService = new TheaterService(dbcontext);
            var theater        = new Theater("someTheater", "Regal", "theater st", "LA", "CA", "US", "323323");

            theaterService.CreateTheater(theater);
            dbcontext.SaveChanges();
            //Arrange
            var controller        = new HelpWantedController();
            TheaterJobPosting job = new TheaterJobPosting(theater.TheaterID, "test", "test", "test", "test", "test", "testType");
            //Act
            var actionResult = controller.CreateTheaterJob(job);
            var response     = actionResult as NegotiatedContentResult <TheaterJobPosting>;
            var content      = response.Content;

            var jobservice = new TheaterJobService(dbcontext);

            jobservice.DeleteTheaterJob(content);
            theaterService.DeleteTheater(theater);
            dbcontext.SaveChanges();
            ////Assert
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Content);
            //Assert.AreEqual("Theater Job Posting Created",content);
            Assert.AreEqual((HttpStatusCode)201, response.StatusCode);
        }
示例#4
0
 public IHttpActionResult CreateTheaterJob([FromBody] TheaterJobPosting theaterJob)
 {
     using (var dbcontext = new BroadwayBuilderContext())
     {
         TheaterJobService jobService = new TheaterJobService(dbcontext);
         try
         {
             if (theaterJob == null)
             {
                 return(Content((HttpStatusCode)400, "That job posting does not exist"));
             }
             jobService.CreateTheaterJob(theaterJob);
             var results = dbcontext.SaveChanges();
             if (results <= 0)
             {
                 throw new ZeroAffectedRowsException();
             }
             return(Content((HttpStatusCode)201, theaterJob));
             //return Content((HttpStatusCode)201, "Theater Job Posting Created");
         }
         catch (ZeroAffectedRowsException)
         {
             return(Content((HttpStatusCode)500, "There appears to be no additions made. The Job posting was not created"));
         }
         catch (DbEntityValidationException)
         {
             return(Content((HttpStatusCode)500, "Unable to create the requested job posting"));
         }
         catch (Exception e)//needs to be updated
         {
             return(Content((HttpStatusCode)400, e.Message));
         }
     }
 }
示例#5
0
        public IHttpActionResult EditTheaterJob(TheaterJobPosting job)
        {
            using (var dbcontext = new BroadwayBuilderContext())
            {
                try
                {
                    TheaterJobService service = new TheaterJobService(dbcontext);
                    //TheaterJobPosting job = service.GetTheaterJob(helpwantedid);
                    if (job != null)
                    {
                        service.UpdateTheaterJob(job);
                        var results = dbcontext.SaveChanges();
                        if (results > 0)
                        {
                            return(Content((HttpStatusCode)202, "Updated Job Posting"));//not sure to return object or just string response
                        }

                        throw new ZeroAffectedRowsException();
                    }
                    else
                    {
                        return(Content((HttpStatusCode)500, "NO such posting exists"));//need to edit
                    }
                }
                catch (ZeroAffectedRowsException)
                {
                    return(Content((HttpStatusCode)500, "There appears to be no changes detected. The Theater Job was not updated"));
                }
                catch (DbEntityValidationException)
                {
                    return(Content((HttpStatusCode)500, "Theater Job could not be updated"));
                }
                catch (Exception e)
                {
                    return(Content((HttpStatusCode)400, e.Message));
                }
            }
        }
示例#6
0
 public IHttpActionResult DeleteTheaterJob(int helpWantedId)
 {
     using (var dbcontext = new BroadwayBuilderContext())
     {
         TheaterJobService service = new TheaterJobService(dbcontext);
         TheaterJobPosting job     = service.GetTheaterJob(helpWantedId);
         try
         {
             service.DeleteTheaterJob(job);
             if (job == null)
             {
                 return(Content((HttpStatusCode)404, "That Job Listing does not exist"));
             }
             var results = dbcontext.SaveChanges();
             if (results > 0)
             {
                 return(Content((HttpStatusCode)202, "Successfully Deleted Job Posting"));
             }
             else
             {
                 throw new ZeroAffectedRowsException();
             }
         }
         catch (ZeroAffectedRowsException)
         {
             return(Content((HttpStatusCode)500, "There appears to be no changes made in the database. The job posting wasn't deleted"));
         }
         catch (DbEntityValidationException)
         {
             return(Content((HttpStatusCode)500, "Unable to delete the job posting"));
         }
         catch (Exception e)
         {
             return(Content((HttpStatusCode)400, e.Message));
         }
     }
 }
示例#7
0
 public IHttpActionResult GetTheaterJobs(int theaterid)//needs to be changed to string for encryption purposes
 {
     using (var dbcontext = new BroadwayBuilderContext())
     {
         try
         {
             TheaterJobService service = new TheaterJobService(dbcontext);
             var list = service.GetAllJobsFromTheater(theaterid);
             if (list == null)
             {
                 throw new NullNotFoundException();
             }
             return(Content((HttpStatusCode)200, list));
         }
         catch (NullNotFoundException)
         {
             return(Content((HttpStatusCode)404, "Unable to find any jobs related to that Theater"));
         }
         catch (Exception e)
         {
             return(Content((HttpStatusCode)400, e.Message));
         }
     }
 }