예제 #1
0
        public async Task <SaveGradeSitePromotionsResponse> SaveGradeSitePromotions(SaveGradeSitePromotionsRequest request)
        {
            var toSave     = new List <AdmGradeSitePromotion>();
            var promotions = _repository.GetQueryable <AdmGradeSitePromotion>().ToList();
            await _repository.DeleteAsync <AdmGradeSitePromotion>(promotions);

            var modelsList = request.Promotions.Where(l => l.PromotingPosGradeID.HasValue && l.PromotingPosGradeID != 0);

            foreach (var model in modelsList)
            {
                DateTime today = _repository.GetSchoolNow(model.AdmSiteID);
                var      site  = promotions.FirstOrDefault(s => s.AdmSiteID == model.AdmSiteID);
                if (site == null)
                {
                    site = new AdmGradeSitePromotion()
                    {
                        AdmSiteID       = model.AdmSiteID,
                        PosGradeID      = model.PromotingPosGradeID ?? 0,
                        LastUpdatedBy   = request.AdmSiteId,
                        LastUpdatedDate = today
                    };
                }

                if (site.PosGradeID != model.PromotingPosGradeID || site.PromoteToAdmSiteID != model.PromoteToAdmSiteID)
                {
                    site.LastUpdatedBy   = request.AdmSiteId;
                    site.LastUpdatedDate = today;
                }

                site.PosGradeID         = model.PromotingPosGradeID ?? 0;
                site.PromoteToAdmSiteID = model.PromoteToAdmSiteID;
                toSave.Add(site);
            }

            var createdPromotions = await _repository.CreateAsync <AdmGradeSitePromotion>(toSave);

            return(new SaveGradeSitePromotionsResponse
            {
                Items = _autoMapper.Map <ICollection <SavedSitePromotionModel> >(createdPromotions)
            });
        }
예제 #2
0
 public async Task <SaveGradeSitePromotionsResponse> SaveGradeSitePromotions(SaveGradeSitePromotionsRequest request)
 {
     return(await _yearEndProcessLogic.SaveGradeSitePromotions(request));
 }