public void DeleteSchoolRoute(long schoolId, SchoolRouteView view)
        {
            view.RecordStatus = SysMngConfig.Lookups.GetItem <SysMngConfig.RecordStatuses>((long)SysMngConfig.RecordStatuses.Deleted);
            var model = _repository.GetById <SchoolRoute>(view.Id);

            view.SetTo(model);
            _repository.Update(model);
        }
        public void CreateSchoolRoute(long schoolId, SchoolRouteView view)
        {
            view.RecordStatus = SysMngConfig.Lookups.GetItem <SysMngConfig.RecordStatuses>((long)SysMngConfig.RecordStatuses.Active);
            var school = _repository.GetById <School>(schoolId);
            var model  = view.ToModel();

            model.School = school;
            school.SchoolRoutes.Add(model);
        }
        public void UpdateSchoolRoute(long schoolId, SchoolRouteView view)
        {
            var existingRoute = (from route in _repository.Query <SchoolRoute>()
                                 where
                                 route.MealType == view.MealType.Id &&
                                 route.RecordStatus == (long)SysMngConfig.RecordStatuses.Active &&
                                 route.Id != view.Id &&
                                 route.School.Id == schoolId
                                 select route).FirstOrDefault();

            if (existingRoute != null)
            {
                throw new ApplicationException("The Meal Type and Route definition already exists.");
            }

            view.RecordStatus = SysMngConfig.Lookups.GetItem <SysMngConfig.RecordStatuses>((long)SysMngConfig.RecordStatuses.Active);

            var model = _repository.GetById <SchoolRoute>(view.Id);

            view.SetTo(model);
            _repository.Update(model);
        }
Beispiel #4
0
 public static void SetTo(this SchoolRouteView view, SchoolRoute model)
 {
     Mapper.Map(view, model);
 }
Beispiel #5
0
 public static SchoolRoute ToModel(this SchoolRouteView view)
 {
     return(Mapper.Map <SchoolRoute>(view));
 }