public async Task <HttpResponseMessage> Create(ProjectRequest req)
        {
            IProject p = new Project();

            req.CopyRequestToProject(p);
            var ep  = new ProjectProcessor(p);
            var res = await ep.Create();

            if (res != null && res.Success)
            {
                return(new HttpResponseMessage()
                {
                    Content = new StringContent(JsonConvert.SerializeObject(new { Id = res.Data.Id.ToString() }))
                });
            }
            return(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest));
        }
示例#2
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.");
        }