Ejemplo n.º 1
0
        public PartialViewResult Edit(FundingSourcePrimaryKey fundingSourcePrimaryKey)
        {
            var fundingSource = fundingSourcePrimaryKey.EntityObject;
            var viewModel     = new EditViewModel(fundingSource);

            return(ViewEdit(viewModel));
        }
Ejemplo n.º 2
0
        private PartialViewResult ViewEdit(EditViewModel viewModel)
        {
            var organizationsAsSelectListItems =
                HttpRequestStorage.DatabaseEntities.Organizations.GetActiveOrganizations()
                .ToSelectListWithEmptyFirstRow(x => x.OrganizationID.ToString(CultureInfo.InvariantCulture), x => x.OrganizationName);
            var viewData = new EditViewData(organizationsAsSelectListItems, CurrentPerson);

            return(RazorPartialView <Edit, EditViewData, EditViewModel>(viewData, viewModel));
        }
Ejemplo n.º 3
0
        public ActionResult Edit(FundingSourcePrimaryKey fundingSourcePrimaryKey, EditViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewEdit(viewModel));
            }
            var fundingSource = fundingSourcePrimaryKey.EntityObject;

            viewModel.UpdateModel(fundingSource, CurrentPerson);
            return(new ModalDialogFormJsonResult());
        }
Ejemplo n.º 4
0
        public PartialViewResult New()
        {
            var viewModel = new EditViewModel
            {
                // If the person is not an admin, we want to default the Funding Source organization to their own Organization
                OrganizationID = new List <Role> {
                    Role.Admin, Role.SitkaAdmin
                }.Any(x => x.RoleID == CurrentPerson.RoleID)
                    ? (int?)null
                    : CurrentPerson.OrganizationID,
                IsActive = true
            };

            return(ViewEdit(viewModel));
        }
Ejemplo n.º 5
0
        public ActionResult New(EditViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewEdit(viewModel));
            }
            var fundingSource = new FundingSource(
                viewModel.OrganizationID ?? ModelObjectHelpers.NotYetAssignedID, // Should never be null due to View Model validation
                string.Empty,
                true);

            viewModel.UpdateModel(fundingSource, CurrentPerson);
            HttpRequestStorage.DatabaseEntities.FundingSources.Add(fundingSource);
            HttpRequestStorage.DatabaseEntities.SaveChanges();
            SetMessageForDisplay($"{FieldDefinitionType.FundingSource.GetFieldDefinitionLabel()} {fundingSource.GetDisplayNameAsUrl()} succesfully created.");

            return(new ModalDialogFormJsonResult());
        }