/// <summary> /// View School Period By Id /// </summary> /// <param name="schoolPeriod"></param> /// <returns></returns> public SchoolPeriodAddViewModel ViewSchoolPeriod(SchoolPeriodAddViewModel schoolPeriod) { return(null); //try //{ // SchoolPeriodAddViewModel schoolPeriodView = new SchoolPeriodAddViewModel(); // var schoolPeriodById = this.context?.SchoolPeriods.FirstOrDefault(x => x.TenantId == schoolPeriod.tableSchoolPeriods.TenantId && x.SchoolId == schoolPeriod.tableSchoolPeriods.SchoolId && x.PeriodId == schoolPeriod.tableSchoolPeriods.PeriodId); // if (schoolPeriodById != null) // { // schoolPeriodView.tableSchoolPeriods = schoolPeriodById; // return schoolPeriodView; // } // else // { // schoolPeriodView._failure = true; // schoolPeriodView._message = NORECORDFOUND; // return schoolPeriodView; // } //} //catch (Exception es) //{ // throw; //} }
/// <summary> /// Update the School Period /// </summary> /// <param name="schoolPeriod"></param> /// <returns></returns> public SchoolPeriodAddViewModel UpdateSchoolPeriod(SchoolPeriodAddViewModel schoolPeriod) { try { var schoolPeriodUpdate = this.context?.SchoolPeriods.FirstOrDefault(x => x.TenantId == schoolPeriod.tableSchoolPeriods.TenantId && x.SchoolId == schoolPeriod.tableSchoolPeriods.SchoolId && x.PeriodId == schoolPeriod.tableSchoolPeriods.PeriodId); schoolPeriodUpdate.TenantId = schoolPeriod.tableSchoolPeriods.TenantId; schoolPeriodUpdate.SchoolId = schoolPeriod.tableSchoolPeriods.SchoolId; schoolPeriodUpdate.PeriodId = schoolPeriod.tableSchoolPeriods.PeriodId; schoolPeriodUpdate.AcademicYear = schoolPeriod.tableSchoolPeriods.AcademicYear; schoolPeriodUpdate.SortOrder = schoolPeriod.tableSchoolPeriods.SortOrder; schoolPeriodUpdate.Title = schoolPeriod.tableSchoolPeriods.Title; schoolPeriodUpdate.ShortName = schoolPeriod.tableSchoolPeriods.ShortName; schoolPeriodUpdate.Length = schoolPeriod.tableSchoolPeriods.Length; schoolPeriodUpdate.Block = schoolPeriod.tableSchoolPeriods.Block; schoolPeriodUpdate.IgnoreScheduling = schoolPeriod.tableSchoolPeriods.IgnoreScheduling; schoolPeriodUpdate.Attendance = schoolPeriod.tableSchoolPeriods.Attendance; schoolPeriodUpdate.RolloverId = schoolPeriod.tableSchoolPeriods.RolloverId; schoolPeriodUpdate.StartTime = schoolPeriod.tableSchoolPeriods.StartTime; schoolPeriodUpdate.EndTime = schoolPeriod.tableSchoolPeriods.EndTime; schoolPeriodUpdate.LastUpdated = schoolPeriod.tableSchoolPeriods.LastUpdated; schoolPeriodUpdate.UpdatedBy = schoolPeriod.tableSchoolPeriods.UpdatedBy; this.context?.SaveChanges(); schoolPeriod._failure = false; return(schoolPeriod); } catch (Exception ex) { schoolPeriod.tableSchoolPeriods = null; schoolPeriod._failure = true; schoolPeriod._message = NORECORDFOUND; return(schoolPeriod); } }
public ActionResult <SchoolPeriodAddViewModel> ViewSchoolPeriod(SchoolPeriodAddViewModel schoolPeriod) { SchoolPeriodAddViewModel schoolPeriodView = new SchoolPeriodAddViewModel(); try { if (schoolPeriod.tableSchoolPeriods.SchoolId > 0) { schoolPeriodView = _schoolPeriodService.ViewSchoolPeriod(schoolPeriod); } else { schoolPeriodView._token = schoolPeriod._token; schoolPeriodView._tenantName = schoolPeriod._tenantName; schoolPeriodView._failure = true; schoolPeriodView._message = "Please enter valid scholl id"; } } catch (Exception es) { schoolPeriodView._failure = true; schoolPeriodView._message = es.Message; } return(schoolPeriodView); }
/// <summary> /// Adding School Period /// </summary> /// <param name="schoolPeriod"></param> /// <returns></returns> public SchoolPeriodAddViewModel AddSchoolPeriod(SchoolPeriodAddViewModel schoolPeriod) { int?MasterSchoolPeriodId = Utility.GetMaxPK(this.context, new Func <SchoolPeriods, int>(x => x.PeriodId)); schoolPeriod.tableSchoolPeriods.PeriodId = (int)MasterSchoolPeriodId; schoolPeriod.tableSchoolPeriods.LastUpdated = DateTime.UtcNow; this.context?.SchoolPeriods.Add(schoolPeriod.tableSchoolPeriods); this.context?.SaveChanges(); schoolPeriod._failure = false; return(schoolPeriod); }
/// <summary> /// View School Period By Id /// </summary> /// <param name="schoolPeriod"></param> /// <returns></returns> public SchoolPeriodAddViewModel ViewSchoolPeriod(SchoolPeriodAddViewModel schoolPeriod) { SchoolPeriodAddViewModel schoolPeriodView = new SchoolPeriodAddViewModel(); if (TokenManager.CheckToken(schoolPeriod._tenantName + schoolPeriod._userName, schoolPeriod._token)) { schoolPeriodView = this.schoolPeriodRepository.ViewSchoolPeriod(schoolPeriod); return(schoolPeriodView); } else { schoolPeriodView._failure = true; schoolPeriodView._message = TOKENINVALID; return(schoolPeriodView); } }
/// <summary> /// Adding School Period /// </summary> /// <param name="schoolPeriod"></param> /// <returns></returns> public SchoolPeriodAddViewModel AddSchoolPeriod(SchoolPeriodAddViewModel schoolPeriod) { //int? MasterSchoolPeriodId = Utility.GetMaxPK(this.context, new Func<SchoolPeriods, int>(x => x.PeriodId)); //int? MasterSchoolPeriodId = 1; //var schoolPeriodData = this.context?.SchoolPeriods.Where(x => x.TenantId == schoolPeriod.tableSchoolPeriods.TenantId && x.SchoolId == schoolPeriod.tableSchoolPeriods.SchoolId).OrderByDescending(x => x.PeriodId).FirstOrDefault(); //if (schoolPeriodData != null) //{ // MasterSchoolPeriodId = schoolPeriodData.PeriodId + 1; //} //schoolPeriod.tableSchoolPeriods.PeriodId = (int)MasterSchoolPeriodId; //schoolPeriod.tableSchoolPeriods.LastUpdated = DateTime.UtcNow; //this.context?.SchoolPeriods.Add(schoolPeriod.tableSchoolPeriods); //this.context?.SaveChanges(); //schoolPeriod._failure = false; return(schoolPeriod); }
/// <summary> /// Delete School Period /// </summary> /// <param name="schoolPeriod"></param> /// <returns></returns> public SchoolPeriodAddViewModel DeleteSchoolPeriod(SchoolPeriodAddViewModel schoolPeriod) { //try //{ // var schoolPeriodDelete = this.context?.SchoolPeriods.FirstOrDefault(x => x.TenantId == schoolPeriod.tableSchoolPeriods.TenantId && x.SchoolId == schoolPeriod.tableSchoolPeriods.SchoolId && x.PeriodId == schoolPeriod.tableSchoolPeriods.PeriodId); // this.context?.SchoolPeriods.Remove(schoolPeriodDelete); // this.context?.SaveChanges(); // schoolPeriod._failure = false; // schoolPeriod._message = "Deleted"; //} //catch (Exception es) //{ // schoolPeriod._failure = true; // schoolPeriod._message = es.Message; //} return(schoolPeriod); }
/// <summary> /// Update the School Period /// </summary> /// <param name="schoolPeriod"></param> /// <returns></returns> public SchoolPeriodAddViewModel UpdateSchoolPeriod(SchoolPeriodAddViewModel schoolPeriod) { return(null); //try //{ // var schoolPeriodUpdate = this.context?.SchoolPeriods.FirstOrDefault(x => x.TenantId == schoolPeriod.tableSchoolPeriods.TenantId && x.SchoolId == schoolPeriod.tableSchoolPeriods.SchoolId && x.PeriodId == schoolPeriod.tableSchoolPeriods.PeriodId); // schoolPeriod.tableSchoolPeriods.LastUpdated = DateTime.UtcNow; // this.context.Entry(schoolPeriodUpdate).CurrentValues.SetValues(schoolPeriod.tableSchoolPeriods); // this.context?.SaveChanges(); // schoolPeriod._failure = false; // return schoolPeriod; //} //catch (Exception ex) //{ // schoolPeriod.tableSchoolPeriods = null; // schoolPeriod._failure = true; // schoolPeriod._message = NORECORDFOUND; // return schoolPeriod; //} }
/// <summary> /// View School Period By Id /// </summary> /// <param name="schoolPeriod"></param> /// <returns></returns> public SchoolPeriodAddViewModel ViewSchoolPeriod(SchoolPeriodAddViewModel schoolPeriod) { try { SchoolPeriodAddViewModel schoolPeriodView = new SchoolPeriodAddViewModel(); var schoolPeriodById = this.context?.SchoolPeriods.FirstOrDefault(x => x.TenantId == schoolPeriod.tableSchoolPeriods.TenantId && x.SchoolId == schoolPeriod.tableSchoolPeriods.SchoolId && x.PeriodId == schoolPeriod.tableSchoolPeriods.PeriodId); if (schoolPeriodById != null) { schoolPeriodView.tableSchoolPeriods = schoolPeriodById; return(schoolPeriodView); } else { schoolPeriodView._failure = true; schoolPeriodView._message = NORECORDFOUND; return(schoolPeriodView); } } catch (Exception es) { throw; } }
/// <summary> /// Delete School Period /// </summary> /// <param name="schoolPeriod"></param> /// <returns></returns> public SchoolPeriodAddViewModel DeleteSchoolPeriod(SchoolPeriodAddViewModel schoolPeriod) { SchoolPeriodAddViewModel schoolPeriodDelete = new SchoolPeriodAddViewModel(); try { if (TokenManager.CheckToken(schoolPeriod._tenantName + schoolPeriod._userName, schoolPeriod._token)) { schoolPeriodDelete = this.schoolPeriodRepository.DeleteSchoolPeriod(schoolPeriod); } else { schoolPeriodDelete._failure = true; schoolPeriodDelete._message = TOKENINVALID; } } catch (Exception es) { schoolPeriodDelete._failure = true; schoolPeriodDelete._message = es.Message; } return(schoolPeriodDelete); }