/// <summary> /// Gets the new period /// </summary> /// <author> Cristian Araya Fuentes </author> /// <param name=pPeriodType> Name of the period type</param> /// <returns></returns> public Period GetNextPeriod(String pPeriodType) { int vNumber = 0, vYear = 0; NuevoPeriodo vLastPeriod = (from PeriodType TP in gvDatabase.PeriodTypes from PeriodNumber N in gvDatabase.PeriodNumbers from Period P in gvDatabase.Periods where TP.Name == pPeriodType where N.ID == P.NumberID where TP.ID == N.TypeID orderby P.Year descending, N.Number descending select new NuevoPeriodo { Number = N.Number, Year = P.Year }).FirstOrDefault(); vNumber = vLastPeriod.Number; vYear = vLastPeriod.Year; if ((vNumber != 0) && (vYear != 0)) { if (pPeriodType == "Semestre") { if (vNumber == 2) { vNumber = 1; vYear += 1; } else { vNumber = 2; } } } Period vPeriod = new Period(); vPeriod.NumberID = vNumber; vPeriod.Year = vYear; return vPeriod; }
// GET: Periodo public ActionResult Index() { gPeriod = AddNewSemester(); int vIdPeriod = getIDPeriod(gPeriod.Year, gPeriod.NumberID); var vResult = gvDatabase.SP_CreateGroupsinNewSemester(vIdPeriod); ViewBag.Period = "" + gPeriod.Year + " - " + gPeriod.NumberID + " Semestre"; ViewBag.IdPeriod = vIdPeriod; return View(getGroupsList(vIdPeriod)); }
public void AddPeriod(Period pPeriod) { gvDatabase.Periods.Add(pPeriod); gvDatabase.SaveChanges(); }