예제 #1
0
        public virtual ActionResult History([ModelBinder(typeof(ImportInnerActionModel))] ImportInnerActionModel innerAction)
        {
            if (innerAction.Equals(ImportModelLevel.Trip, ImportModelAction.Remove))
            {
                var trip = Repositories.Imports.FindById(innerAction.Id);
                if (!User.IsAuthorizedToEdit(trip))
                {
                    return(new UnauthorizedResult());
                }
                Repositories.Imports.Remove(trip);
                Uow.Persist();
                return(View(Mapper.Map <IList <Trip>, IList <ImportTripSummaryModel> >(
                                Repositories.Imports.ListCreatedByUser(User.Id))));
            }

            throw new NotImplementedException();
        }
예제 #2
0
        public virtual ActionResult Trees(
            [ModelBinder(typeof(ImportTreesModelBinder))] ImportTreesModel model,
            [ModelBinder(typeof(ImportInnerActionModel))] ImportInnerActionModel innerAction)
        {
            ModelState.Clear();

            var trip = Repositories.Imports.FindById(model.Id);

            if (!User.IsAuthorizedToEdit(trip))
            {
                return(new UnauthorizedResult());
            }

            trip.InitializeTrees();
            model.Initialize();

            if (innerAction.Equals(ImportModelLevel.Tree, ImportModelAction.SaveUnlessOptionalErrors) ||
                innerAction.Equals(ImportModelLevel.Tree, ImportModelAction.SaveIgnoringOptionalErrors))
            {
                return(SaveTree(model, trip, innerAction.Id, innerAction.Action == ImportModelAction.SaveUnlessOptionalErrors));
            }

            if (innerAction.Equals(ImportModelLevel.Tree, ImportModelAction.Edit))
            {
                return(EditTree(model, trip, innerAction.Id));
            }

            if (innerAction.Equals(ImportModelLevel.Site, ImportModelAction.Add))
            {
                return(AddTree(model, trip, innerAction.Id));
            }

            if (innerAction.Equals(ImportModelLevel.Tree, ImportModelAction.Remove))
            {
                return(RemoveTree(model, trip, innerAction.Id));
            }

            if (innerAction.Equals(ImportModelLevel.Trip, ImportModelAction.SaveUnlessOptionalErrors) ||
                innerAction.Equals(ImportModelLevel.Trip, ImportModelAction.SaveIgnoringOptionalErrors))
            {
                return(SaveTrees(model, trip, innerAction.Action == ImportModelAction.SaveUnlessOptionalErrors));
            }

            throw new NotImplementedException();
        }