public ActionResult CreateOrganization(CreateOrganizationRequestViewModel model)
        {
            if (model == null || !this.ModelState.IsValid)
            {
                this.TempData[GlobalConstants.TempDataErrorKey] = GlobalConstants.InvalidOrganizationRequestErrorMessage;
                return(this.RedirectToAction(x => x.Index()));
            }

            var organizationToCreate = new Organization()
            {
                Name        = model.OrganizationName,
                AboutInfo   = model.OrganizationDescription,
                UserId      = model.UserId,
                PhoneNumber = model.PhoneNumber
            };

            var isCreated = this.organizations.Create(organizationToCreate);

            if (!isCreated)
            {
                this.TempData[GlobalConstants.TempDataErrorKey] = GlobalConstants.InvalidOrganizationRequestErrorMessage;
                return(this.RedirectToAction(x => x.Index()));
            }

            this.TempData[GlobalConstants.TempDataSuccessKey] = GlobalConstants.CreatedOrganizationSuccessMessage;

            this.createOrganizationRequests.ProceedRequest(model.Id);
            return(this.RedirectToAction(x => x.Index()));
        }
        public ActionResult CreateOrganization(CreateOrganizationRequestViewModel model)
        {
            if (model == null || !this.ModelState.IsValid)
            {
                this.TempData[GlobalConstants.TempDataErrorKey] = GlobalConstants.InvalidOrganizationRequestErrorMessage;
                return this.RedirectToAction(x => x.Index());
            }

            var organizationToCreate = new Organization()
            {
                Name = model.OrganizationName,
                AboutInfo = model.OrganizationDescription,
                UserId = model.UserId,
                PhoneNumber = model.PhoneNumber
            };

            var isCreated = this.organizations.Create(organizationToCreate);

            if (!isCreated)
            {
                this.TempData[GlobalConstants.TempDataErrorKey] = GlobalConstants.InvalidOrganizationRequestErrorMessage;
                return this.RedirectToAction(x => x.Index());
            }

            this.TempData[GlobalConstants.TempDataSuccessKey] = GlobalConstants.CreatedOrganizationSuccessMessage;

            this.createOrganizationRequests.ProceedRequest(model.Id);
            return this.RedirectToAction(x => x.Index());
        }
示例#3
0
        public ActionResult Apply(CreateOrganizationRequestViewModel model)
        {
            if (model != null && this.ModelState.IsValid)
            {
                var userId  = this.User.Identity.GetUserId();
                var request = this.Mapper.Map <CreateOrganizationRequest>(model);

                request.UserId = userId;

                this.createOrganizationRequests.CreateRequest(request);
                return(this.RedirectToAction(x => x.ApplicationSuccess()));
            }

            return(this.View("Index", model));
        }
        public ActionResult Apply(CreateOrganizationRequestViewModel model)
        {
            if (model != null && this.ModelState.IsValid)
            {
                var userId = this.User.Identity.GetUserId();
                var request = this.Mapper.Map<CreateOrganizationRequest>(model);

                request.UserId = userId;

                this.createOrganizationRequests.CreateRequest(request);
                return this.RedirectToAction(x => x.ApplicationSuccess());
            }

            return this.View("Index", model);
        }