Esempio n. 1
0
        public bool ObjectExists(TimeTableDTO facilitySubscription)
        {
            var objectExists = false;

            //var iDbContext = DbContextUtil.GetDbContextInstance();
            //try
            //{
            //    var catRepository = new Repository<TimeTableDTO>(iDbContext);
            //    var catExists = catRepository.Query()
            //        .Filter(bp => (bp.SubscriptionId == facilitySubscription.SubscriptionId &&
            //            bp.FacilityId == facilitySubscription.FacilityId)
            //            && bp.Id != facilitySubscription.Id)
            //        .Get()
            //        .FirstOrDefault();

            //    if (catExists != null)
            //        objectExists = true;
            //}
            //finally
            //{
            //    iDbContext.Dispose();
            //}

            return(objectExists);
        }
Esempio n. 2
0
        public string InsertOrUpdate(TimeTableDTO facilitySubscription)
        {
            try
            {
                var validate = Validate(facilitySubscription);
                if (!string.IsNullOrEmpty(validate))
                {
                    return(validate);
                }

                if (ObjectExists(facilitySubscription))
                {
                    return(GenericMessages.DatabaseErrorRecordAlreadyExists + Environment.NewLine +
                           "With the same Name Exists");
                }

                _facilitySubscriptionRepository.InsertUpdate(facilitySubscription);
                _unitOfWork.Commit();
                return(string.Empty);
            }
            catch (Exception exception)
            {
                return(exception.Message);
            }
        }
        public ActionResult EditTimeTableEvents(Guid id)
        {
            TimeTableDTO       timeTableDto       = _timeTableService.GetTimeTableDTOById(id);
            TimeTableViewModel timeTableViewModel = _mapper.Map <TimeTableDTO, TimeTableViewModel>(timeTableDto);

            return(View(timeTableViewModel));
        }
        public Guid AddTimeTable(TimeTableDTO timeTableDTO)
        {
            TimeTable timeTable = _mapper.Map <TimeTableDTO, TimeTable>(timeTableDTO);

            timeTable.Group = Database.Groups.Get(timeTableDTO.GroupId);

            Database.TimeTables.Create(timeTable);
            Database.Save();

            return(timeTable.Id);
        }
Esempio n. 5
0
        public string Validate(TimeTableDTO facilitySubscription)
        {
            if (null == facilitySubscription)
            {
                return(GenericMessages.ObjectIsNull);
            }

            //if (String.IsNullOrEmpty(facilitySubscription.PlateNumber))
            //    return facilitySubscription.PlateNumber + " " + GenericMessages.StringIsNullOrEmpty;

            return(string.Empty);
        }
Esempio n. 6
0
        private void AddNewTimeTable()
        {
            SelectedService   = Services.FirstOrDefault();
            SelectedTimeTable = new TimeTableDTO()
            {
                ClassBegins = DateTime.Now.ToShortTimeString(),
                ClassEnds   = DateTime.Now.ToShortTimeString()
            };

            SelectedTrainers = new ObservableCollection <TrainerDTO>();
            //GetLiveTrainers();
            GetLiveFilteredTrainers(); //FilteredTrainers = new ObservableCollection<TrainerDTO>(Trainers.ToList());

            AllTrainersChecked     = true;
            AddTrainerEnability    = false;
            RemoveTrainerEnability = false;
        }
Esempio n. 7
0
            protected override void OnFinish()
            {
                // only load the data if an update was requested by an Update() call
                if (UpdateType == CallBackUpdateType.None)
                {
                    return;
                }

                DataIdField    = "Id";
                DataStartField = "Start";
                DataEndField   = "End";
                DataTextField  = "Text";

                TimeTableDTO timeTableDto       = _timeTableService.GetTimeTableDTOById(_id);
                var          timeTableViewModel = _mapper.Map <TimeTableDTO, TimeTableViewModel>(timeTableDto);

                Events = timeTableViewModel.Events;
            }
        public ActionResult EditTimeTable(TimeTableViewModel timeTableViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    TimeTableDTO timeTableDto = _mapper.Map <TimeTableViewModel, TimeTableDTO>(timeTableViewModel);

                    _timeTableService.UpdateTimeTable(timeTableDto);
                    return(Json(new { success = true }));
                }
            }
            catch (ValidationException ex)
            {
                ViewBag.Error = ex.Message;
                return(Json(new { success = false, errorMessage = ex.Message }));
            }

            return(PartialView("_EditTimeTableFormPartial", timeTableViewModel));
        }
        public ActionResult AddTimeTable(TimeTableViewModel timeTableViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    GroupDTO     groupDto     = _timeTableService.GetGroupDTOById(new Guid(timeTableViewModel.GroupId));
                    TimeTableDTO timeTableDto = _mapper.Map <TimeTableViewModel, TimeTableDTO>(timeTableViewModel);
                    var          timeTableId  = _timeTableService.AddTimeTable(timeTableDto);
                    return(Json(new { success = true, id = timeTableId, GroupName = groupDto.Name }));
                }
            }
            catch (ValidationException ex)
            {
                ViewBag.Error = ex.Message;
                return(Json(new { success = false, errorMessage = ex.Message }));
            }

            return(PartialView("_AddTimeTableFormPartial", timeTableViewModel));
        }
Esempio n. 10
0
        public string Disable(TimeTableDTO facilitySubscription)
        {
            if (facilitySubscription == null)
            {
                return(GenericMessages.ObjectIsNull);
            }

            string stat;

            try
            {
                _facilitySubscriptionRepository.Update(facilitySubscription);
                _unitOfWork.Commit();
                stat = string.Empty;
            }
            catch (Exception exception)
            {
                stat = exception.Message;
            }
            return(stat);
        }
        public void UpdateTimeTable(TimeTableDTO timeTableDTO)
        {
            //TimeTable timeTable = _mapper.Map<TimeTableDTO, TimeTable>(timeTableDTO);

            //var existingTimeTable = Database.TimeTables.Find(t => t.Id == timeTableDTO.Id).FirstOrDefault();
            //var existingEvents = existingTimeTable.Events.ToList();
            //var updatedEvents = timeTable.Events.ToList();

            //var addedEvents = updatedEvents.Where(e => !existingEvents.Select(ee => ee.Id).Contains(e.Id)).ToList();
            //var deletedEvents = existingEvents.Where(e => !updatedEvents.Select(ee => ee.Id).Contains(e.Id)).ToList();
            //var modifiedEvents = updatedEvents.Where(e => !addedEvents.Select(ee => ee.Id).Contains(e.Id)).ToList();

            //foreach (var addedEvent in addedEvents)
            //{
            //    Database.Events.Create(addedEvent);
            //}


            //Database.TimeTables.Update(timeTable);
            Database.Save();
        }