Beispiel #1
0
        public ActionResult RemoveEventProject(EventAddRemoveProjectVM vm)
        {
            ReturnStatus rs = Repository.RemoveEventProject(vm);

            if (rs.errorCode == ReturnStatus.ALL_CLEAR)
            {
                // TODO: notify project removed
            }
            else
            {
                // TODO: notify removal failed
            }
            return(RedirectToAction("ManageEvent", new { id = vm.hfhEventId }));
        }
        /// <summary>
        /// Deletes the relationship between an HfhEvent
        /// and a Project
        /// </summary>
        /// <param name="vm">An EventAddRemoveProjectVM</param>
        /// <returns>Returns an errorCode describing the result from the database</returns>
        public static ReturnStatus RemoveEventProject(EventAddRemoveProjectVM vm)
        {
            ReturnStatus       rs = new ReturnStatus();
            VolunteerDbContext db = new VolunteerDbContext();

            try
            {
                ProjectEvent pe = db.eventProjects.Where(e => e.project_Id == vm.projectId && e.event_Id == vm.hfhEventId).ToList().FirstOrDefault();
                db.eventProjects.Remove(pe);
                db.SaveChanges();
                rs.errorCode = ReturnStatus.ALL_CLEAR;
            }
            catch
            {
                rs.errorCode = ReturnStatus.COULD_NOT_UPDATE_DATABASE;
            }

            return(rs);
        }