Example #1
0
        public void TestProjectCRUD()
        {
            IProject p = CreateProject();

            var pp   = new ProjectProcessor(p);
            var save = pp.Create().Result;

            Assert.IsTrue(save.Data != null && save.Data.Id != Guid.Empty, "Project save failed.");

            var one = pp.FetchById().Result;

            Assert.IsTrue(one.Data != null, "Project fetch failed.");

            var eHelper = new EventProcessor(p.Events[0].Id);
            var eOne    = eHelper.FetchById().Result;

            Assert.IsTrue(eOne.Data != null, "Event fetch failed.");

            var delete = pp.Delete().Result;

            one = pp.FetchById().Result;
            Assert.IsTrue(one.Data == null, "Project delete failed.");

            eOne = eHelper.FetchById().Result;
            Assert.IsTrue(eOne.Data == null, "Event delete failed from Project.");

            var vhelper = new VendorProcessor(p.Events[0].Arrangements[0].Vendor.Id);

            delete = vhelper.Delete().Result;

            var vendor = vhelper.FetchById().Result;

            Assert.IsTrue(one.Data == null, "Vendor delete failed.");

            var uHelper = new UserProcessor(p.Events[0].Arrangements[0].Vendor.Id);
            var user    = uHelper.FetchById().Result;

            Assert.IsTrue(user.Data == null, "User not deleted from vendor delete.");
        }
        public async Task <HttpResponseMessage> Get(Guid id)
        {
            if (id != Guid.Empty)
            {
                var ep = new ProjectProcessor(id);
                var e  = await ep.FetchById();

                if (e.Data != null)
                {
                    return(new HttpResponseMessage()
                    {
                        Content = new StringContent(JsonConvert.SerializeObject(e.Data))
                    });
                }
                else
                {
                    return(new HttpResponseMessage(System.Net.HttpStatusCode.NotFound));
                }
            }
            return(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest));
        }