コード例 #1
0
        public ActionResult Delete()
        {
            if (userContext.ItemId == null)
            {
                return(HttpNotFound());
            }
            var model = new DeleteOrganisationViewModel(userContext.ItemId.Value);

            model.Populate(db);
            return(View(model));
        }
コード例 #2
0
        public async Task <ActionResult> Delete(DeleteOrganisationViewModel model)
        {
            Organisation organisation = await db.Organisations.FindAsync(userContext.ItemId);

            if (organisation.OrganisationProviders.Any(x => x.IsAccepted && !x.IsRejected))
            {
                return(Delete());
            }

            organisation.RecordStatusId = (int)Constants.RecordStatus.Deleted;
            await db.SaveChangesAsync();

            // Reset the user's current context and find out what it is
            UserContext.UserContextInfo defaultContext = UserContext.InstantiateSession();
            if (defaultContext.ContextName != UserContext.UserContextName.Administration)
            {
                IAuthenticationManager authenticationManager = HttpContext.GetOwinContext().Authentication;
                authenticationManager.SignOut();
                SessionManager.End();
            }
            ShowGenericSavedMessage();
            return(RedirectToAction("Index", "Home"));
        }