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));
        }
示例#2
0
 public AllAnnualAgreementsGetResponse AllAnnualAgreementsByYear(SchoolAnnualAgreementRequest request)
 {
     return(Execute <SchoolAnnualAgreementRequest, AllAnnualAgreementsGetResponse>(
                request,
                response =>
     {
         response.SchoolAnnualAgreements = SchoolFacade.AllAnnualAgreementsByYear(request.SchoolAnnualAgreement.Year);
     }
                ));
 }
示例#3
0
 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);
     }));
 }
示例#4
0
        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 }));
        }
示例#6
0
 public SchoolAnnualAgreementGetResponse GetSchoolAnnualAgreement(SchoolAnnualAgreementRequest request)
 {
     return(Execute <SchoolAnnualAgreementRequest, SchoolAnnualAgreementGetResponse>(
                request,
                response => response.SchoolAnnualAgreement = SchoolFacade.GetSchoolAnnualAgreement(request.SchoolAnnualAgreement.Id)));
 }
示例#7
0
 public VoidResponse DeleteSchoolAnnualAgreement(SchoolAnnualAgreementRequest request)
 {
     return(Execute <SchoolAnnualAgreementRequest, VoidResponse>(
                request,
                response => SchoolFacade.DeleteAnnualAgreement(request.SchoolId, request.SchoolAnnualAgreement)));
 }