public ActionResult DeletePromotionParticipation(int PromotionParticipationId) { try { PromotionParticipation a = PromotionParticipationRep.Get(PromotionParticipationId); int InstId = (int)a.institution_id; PromotionParticipationRep.Delete(a); UpdateLastPromotion(InstId); return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddNewPromotionParticipation(int InstId, int PromotionId) { try { PromotionParticipation a = new PromotionParticipation() { promotion_id = PromotionId, institution_id = InstId }; PromotionParticipationRep.AddOrUpdate(a); return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult UpdateLastPromotion(int InstId) { List <PromotionParticipation> PromotionParticipations = PromotionParticipationRep.FindBy(i => i.institution_id == InstId).OrderByDescending(i => i.Promotion.date_end).ToList(); Institution inst = InstitutionRep.Get(InstId); if (PromotionParticipations.Any()) { PromotionParticipation p = PromotionParticipations.First(); inst.last_promotion_id = p.promotion_id; inst.last_promo_end_date = p.Promotion.date_end; } else { inst.last_promotion_id = null; inst.last_promo_end_date = null; } InstitutionRep.AddOrUpdate(inst); return(new EmptyResult()); }