public ActionResult EditAnnualAgreement(int id, int?annualAgreementId) { var annualAgreement = new SchoolAnnualAgreementRequest { SchoolId = id, SchoolAnnualAgreement = new SchoolAnnualAgreementView { ItemType = Lookups.GetItem <AnnualItemTypes>((long)AnnualItemTypes.None), RecordStatus = SysMngConfig.Lookups.GetItem <SysMngConfig.RecordStatuses>((long)SysMngConfig.RecordStatuses.Active) } }; if (annualAgreementId.HasValue && annualAgreementId.Value > 0) { annualAgreement.SchoolAnnualAgreement = SchoolService.GetSchoolAnnualAgreement( new SchoolAnnualAgreementRequest { SchoolId = id, SchoolAnnualAgreement = new SchoolAnnualAgreementView { Id = annualAgreementId.Value } }).SchoolAnnualAgreement; } //ViewBag.MealTypes =Lookups.GetItems<MealTypes>().Select(d=>new SelectListItem{Selected = d.Id==annualAgreement.SchoolAnnualAgreement.MealType.Id,Text=d.Text,Value = d.Id.ToString()}).ToList(); ViewBag.AnnualItemTypes = Lookups.GetItems <AnnualItemTypes>().Select(d => new SelectListItem { Selected = (d.Id == annualAgreement.SchoolAnnualAgreement.ItemType.Id), Text = d.Text, Value = d.Id.ToString() }).ToList(); return(View(annualAgreement)); }
public AllAnnualAgreementsGetResponse AllAnnualAgreementsByYear(SchoolAnnualAgreementRequest request) { return(Execute <SchoolAnnualAgreementRequest, AllAnnualAgreementsGetResponse>( request, response => { response.SchoolAnnualAgreements = SchoolFacade.AllAnnualAgreementsByYear(request.SchoolAnnualAgreement.Year); } )); }
public VoidResponse CreateSchoolAnnualAgreement(SchoolAnnualAgreementRequest request) { return(Execute <SchoolAnnualAgreementRequest, VoidResponse>( request, response => { var yearAnnuals = SchoolFacade.AnnualAgreementsByFilter(request.SchoolId, request.SchoolAnnualAgreement.Year, request.SchoolAnnualAgreement.ItemType.Id); if (yearAnnuals.Any()) { throw new Exception(string.Format("{0}, {1} Annual Agrement Exist", request.SchoolAnnualAgreement.Year, request.SchoolAnnualAgreement.ItemType)); } SchoolFacade.CreateAnnualAgreement(request.SchoolId, request.SchoolAnnualAgreement); })); }
public SchoolAnnualAgreementGetResponse GetAnnualAggrementByIdAndYear(SchoolAnnualAgreementRequest request) { return(Execute <SchoolAnnualAgreementRequest, SchoolAnnualAgreementGetResponse>( request, response => response.SchoolAnnualAgreement = new SchoolAnnualAgreementView { Price = SchoolFacade.AnnualAgreementsByYearAndId(request.SchoolId, request.SchoolAnnualAgreement.Year).First().Value, Year = SchoolFacade.AnnualAgreementsByYearAndId(request.SchoolId, request.SchoolAnnualAgreement.Year).First().Key } )); }
public ActionResult EditAnnualAgreement(SchoolAnnualAgreementRequest request) { var actionParam = Request["actionParam"]; if (ModelState.IsValid) { if (request.SchoolAnnualAgreement.Id > 0) { if (actionParam == "S") { var updateResponse = SchoolService.UpdateSchoolAnnualAgreement(request); if (updateResponse.Result == Result.Failed) { ErrorMessage = updateResponse.Message; } } else { var deleteResponse = SchoolService.DeleteSchoolAnnualAgreement(request); if (deleteResponse.Result == Result.Failed) { ErrorMessage = deleteResponse.Message; } } } else { var createResponse = SchoolService.CreateSchoolAnnualAgreement(request); if (createResponse.Result == Result.Failed) { ErrorMessage = createResponse.Message; } } } return(RedirectToAction("Edit", "School", new { id = request.SchoolId })); }
public SchoolAnnualAgreementGetResponse GetSchoolAnnualAgreement(SchoolAnnualAgreementRequest request) { return(Execute <SchoolAnnualAgreementRequest, SchoolAnnualAgreementGetResponse>( request, response => response.SchoolAnnualAgreement = SchoolFacade.GetSchoolAnnualAgreement(request.SchoolAnnualAgreement.Id))); }
public VoidResponse DeleteSchoolAnnualAgreement(SchoolAnnualAgreementRequest request) { return(Execute <SchoolAnnualAgreementRequest, VoidResponse>( request, response => SchoolFacade.DeleteAnnualAgreement(request.SchoolId, request.SchoolAnnualAgreement))); }