Exemplo n.º 1
0
        /// <summary>
        /// Here we keep track of all the moderator happenings & associated post content
        /// </summary>
        /// <param name="obj"></param>
        public void DeleteClimbOutdoor(ClimbOutdoor obj)
        {
            var meta = DeleteClimbOutdoorAuthorization(obj);

            DeleteClimb(obj);

            var modWhoAdded = modProfileRepo.GetByID(meta.CreatedByUserID);

            if (modWhoAdded.ClimbsAdded > 0)
            {
                modWhoAdded.ClimbsAdded--;
                modProfileRepo.Update(modWhoAdded);

                //-- Remove the points associated with this place
                var actionsWithPoints = modActionRepo.GetAll().Where(a => a.OnObjectID == meta.ID);
                ReverseActions(actionsWithPoints);
            }

            //-- update the principal details with the details we just updated (if they are the same person who deleted it)
            CfPrincipal.AttachModProfile(modProfileRepo.GetByID(currentUser.UserID));
            meta.Name = obj.Name;

            var action = SaveModActionAndUpdateModProfile(ModActionType.ClimbDelete, obj, null, meta,
                                                          (m, actionID) => m.SetDeleted(actionID), null, "deleted climb {0}", obj.Name);

            postSvc.DeleteContentAddPost(action);
            //-- TODO: Shoot off notifications to claimed users
        }
Exemplo n.º 2
0
        public ClimbOutdoor UpdateOutdoor(ClimbOutdoor climb)
        {
            var set         = Ctx.CreateObjectSet <Climb>();
            var tEntityInDB = GetOutdoorClimbByID(climb.ID);

            set.ApplyCurrentValues(climb);
            SaveChanges();
            return(climb);
        }
Exemplo n.º 3
0
        public ClimbOutdoor CreateClimbOutdoor(ClimbOutdoor obj, List <int> categories)
        {
            var user = CfPerfCache.GetClimber(CfIdentity.UserID);

            //-- The tricky part about this, it that using the Action/Lambda we call create with the ClimbOutdoor type argument
            var meta = CreateClimb(obj, categories, CfType.ClimbOutdoor, () => climbRepo.Create(obj));

            ClaimObject(obj); // note we only claim outdoor climbs, not indoor....

            var action = SaveModActionAndUpdateModProfile(ModActionType.ClimbAdd, null, (Climb)obj, meta,
                                                          (m, actionID) => m.SetCreated(actionID), mp => mp.ClimbsAdded++, "added climb {0}", obj.Name);

            postSvc.CreateContentAddPost(action, obj.LocationID, user.PrivacyPostsDefaultIsPublic);

            return(obj);
        }
Exemplo n.º 4
0
        public ActionResult ClimbOutdoorNew(Guid id, ClimbOutdoorNewViewModel m)
        {
            var location = geoSvc.GetLocationOutdoorByID(id);

            if (location == default(LocationOutdoor))
            {
                return(RedirectToAction("ClimbNewPrestep"));
            }

            if (ModelState.IsValid)
            {
                var climb = new ClimbOutdoor();
                climb.InjectFrom(m);
                climb.CountryID = location.CountryID;

                geoSvc.CreateClimbOutdoor(climb, m.Categories);

                return(Redirect(climb.SlugUrl));
            }
            else
            {
                return(View("ClimbOutdoorNew", m));
            }
        }
Exemplo n.º 5
0
 public ClimbOutdoor UpdateClimbOutdoor(ClimbOutdoor original, ClimbOutdoor updated, List <int> categories)
 {
     return(UpdateClimb(original, updated, categories, c => climbRepo.UpdateOutdoor(c)));
 }
        public ActionResult ClimbOutdoorNew(Guid id, ClimbOutdoorNewViewModel m)
        {
            var location = geoSvc.GetLocationOutdoorByID(id);
            if (location == default(LocationOutdoor)) { return RedirectToAction("ClimbNewPrestep"); }

            if (ModelState.IsValid)
            {
                var climb = new ClimbOutdoor();
                climb.InjectFrom(m);
                climb.CountryID = location.CountryID;

                geoSvc.CreateClimbOutdoor(climb, m.Categories);

                return Redirect(climb.SlugUrl);
            }
            else
            {
                return View("ClimbOutdoorNew", m);
            }
        }