예제 #1
0
        public async Task <IEnumerable <HoraryViewModel> > GetHoraryDrop(int type, int fieldItem, DateTime date, int horaryId)
        {
            List <HoraryViewModel> list = new List <HoraryViewModel>();
            var result = await _schedulingRepository.GetAll();


            if (type == 1)
            {
                int dayOfWeek = (int)date.DayOfWeek;

                var horary = await _horaryRepository.GetAll();

                foreach (var item in horary.Where(p => p.FieldItemId == fieldItem && p.DayWeek == dayOfWeek && p.State == true && p.Active == true))
                {
                    Scheduling scheduling = result.Where(p => p.Date == date && p.HoraryType == HoraryType.Default && p.HoraryId == item.Id).FirstOrDefault();

                    if (scheduling == null)
                    {
                        var newItem = new HoraryViewModel {
                            Hour = item.Hour, Id = item.Id
                        };
                        list.Add(newItem);
                    }
                    else
                    {
                        if (horaryId == scheduling.HoraryId)
                        {
                            var newItem = new HoraryViewModel {
                                Hour = item.Hour, Id = item.Id
                            };
                            list.Add(newItem);
                        }
                    }
                }
            }
            else
            {
                var horaryExtra = await _horaryExtraRepository.GetAll();

                foreach (var item in horaryExtra.Where(p => p.FieldItemId == fieldItem && p.Date == date))
                {
                    Scheduling scheduling = result.Where(p => p.Date == date && p.HoraryType == HoraryType.Extra && p.HoraryId == item.Id).FirstOrDefault();

                    if (scheduling == null)
                    {
                        var newItem = new HoraryViewModel {
                            Hour = item.Hour, Id = item.Id
                        };
                        list.Add(newItem);
                    }
                    else
                    {
                        if (horaryId == scheduling.HoraryId)
                        {
                            var newItem = new HoraryViewModel {
                                Hour = item.Hour, Id = item.Id
                            };
                            list.Add(newItem);
                        }
                    }
                }
            }

            return(list.OrderBy(p => p.Hour).Select(_mapper.Map <HoraryViewModel>));
        }
예제 #2
0
 public void Add(HoraryViewModel fieldViewModel)
 {
     _horaryRepository.Add(_mapper.Map <Horary>(fieldViewModel));
 }
예제 #3
0
 public void Put([FromBody] HoraryViewModel horaryPriceViewModel)
 {
     _horaryAppService.Update(horaryPriceViewModel);
 }
예제 #4
0
 public void Update(HoraryViewModel fieldViewModel)
 {
     _horaryRepository.Update(_mapper.Map <Horary>(fieldViewModel));
 }
예제 #5
0
 public void Post([FromBody] HoraryViewModel horaryPriceViewModel)
 {
     _horaryAppService.Add(horaryPriceViewModel);
 }