Exemplo n.º 1
0
        public bool CreateOrganization(OrganizationCreate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var newOrganization = new Organization()
                {
                    Name = model.Name
                };

                ctx.Organizations.Add(newOrganization);
                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Create(OrganizationCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (new OrganizationService().CreateOrganization(model))
            {
                TempData["SaveResult"] = "Organization established";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Something went wrong - could not create an organization");
            return(View(model));
        }
Exemplo n.º 3
0
        public bool CreateOrganization(OrganizationCreate model)
        {
            var entity =
                new Organization()
            {
                Name        = model.Name,
                Description = model.Description,
                BoroughId   = model.BoroughId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Organizations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public IHttpActionResult Post(OrganizationCreate organization)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateOrganizationService();

            if (!service.CreateOrganization(organization))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Exemplo n.º 5
0
        public bool CreateOrganization(OrganizationCreate model)
        {
            var entity =
                new Organization()
            {
                OwnerID          = _userId,
                OrganizationName = model.OrganizationName,
                OrganizationLink = model.OrganizationLink,
                OrganizationBio  = model.OrganizationBio
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.OrganizationTable.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public bool CreateOrganization(OrganizationCreate model)
        {
            var entity = new Organization()
            {
                OwnerId              = _userId,
                OrganizationName     = model.OrganizationName,
                OrganizationAddress  = model.OrganizationAddress,
                OrganizationIndustry = model.OrganizationIndustry,
                CreatedUtc           = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Organizations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 7
0
        public ActionResult Create(OrganizationCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = new OrganizationService();

            if (service.CreateOrganization(model))
            {
                TempData["SaveResult"] = "Your organization was created.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Organization could not be created");

            return(View(model));
        }
 public void Init()
 {
     instance = new OrganizationCreate();
 }