Esempio n. 1
0
        public ActionResult CreateEventSubscription(int eventId, int subscriptionId)
        {
            var approvalStatusId     = _lookupRepo.GetApprovalStatuses().SingleOrDefault(p => p.Name.Equals("New")).Id;
            var eventSubscriptionRel = new EventSubscriptionRel
            {
                SubscriptionId   = subscriptionId,
                EventId          = eventId,
                ApprovalStatusId = approvalStatusId,
                DateStart        = DateTime.Now,
            };

            if (subscriptionId == -1)
            {
                eventSubscriptionRel.Subscription = new Subscription();
                ViewBag.PossibleRelationshipTypes = _lookupRepo.GetRelationshipTypes().Where(x => x.ObjectFrom.Equals("Event") && x.ObjectTo.Equals("Subscription")).OrderBy(x => x.SortOrder);
                ViewBag.Controller = "Events";
                ViewBag.EventId    = eventId;
            }
            else
            {
                eventSubscriptionRel.Event        = new Event();
                ViewBag.PossibleRelationshipTypes = _lookupRepo.GetRelationshipTypes().Where(x => x.ObjectFrom.Equals("Subscription") && x.ObjectTo.Equals("Event")).OrderBy(x => x.SortOrder);
                ViewBag.Controller     = "Subscriptions";
                ViewBag.SubscriptionId = subscriptionId;
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_CreateOrEditEventSubscription", eventSubscriptionRel));
            }

            return(View());
        }
Esempio n. 2
0
 public void InsertOrUpdateEventSubscription(EventSubscriptionRel eventsubscriptionrel)
 {
     if (eventsubscriptionrel.Id == default(int))
     {
         // New entity
         _ctx.EventSubscriptionRels.Add(eventsubscriptionrel);
     }
     else
     {
         // Existing entity
         _ctx.Entry(eventsubscriptionrel).State = EntityState.Modified;
     }
 }
Esempio n. 3
0
 public ActionResult CreateEventSubscription([Bind(Include = "Id,RelationshipTypeId,DateStart,DateEnd,EventId,SubscriptionId")] EventSubscriptionRel eventSubscriptionRel)
 {
     if (ModelState.IsValid)
     {
         if (eventSubscriptionRel.Event == null)
         {
             eventSubscriptionRel.Subscription = null;
             _eventRepo.InsertOrUpdateEventSubscription(eventSubscriptionRel);
             _eventRepo.Save();
             return(RedirectToAction("Details", "Events", new { id = eventSubscriptionRel.EventId }));
         }
         else
         {
             //reset the organization object.  This is only added from Organization, not EventOrganizationRel.
             eventSubscriptionRel.Event = null;
             _eventRepo.InsertOrUpdateEventSubscription(eventSubscriptionRel);
             _eventRepo.Save();
             return(RedirectToAction("Details", "Subscriptions", new { id = eventSubscriptionRel.SubscriptionId }));
         }
     }
     return(View());
 }