Exemplo n.º 1
0
        private WeekDayDTO Create(WeekDayViewModel viewModel)
        {
            try
            {
                log.Debug(WeekDayViewModel.FormatWeekDayViewModel(viewModel));

                WeekDayDTO weekDay = new WeekDayDTO();

                // copy values
                viewModel.UpdateDTO(weekDay, null); //RequestContext.Principal.Identity.GetUserId());

                // audit
                weekDay.CreateBy = null; //RequestContext.Principal.Identity.GetUserId();
                weekDay.CreateOn = DateTime.UtcNow;

                // add
                log.Debug("_weekDayService.AddWeekDay - " + WeekDayDTO.FormatWeekDayDTO(weekDay));

                int id = _weekDayService.AddWeekDay(weekDay);

                weekDay.WeekDayId = id;

                log.Debug("result: 'success', id: " + id);

                return(weekDay);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Exemplo n.º 2
0
        public WeekDayDTO GetWeekDay(int weekDayId)
        {
            try
            {
                //Requires.NotNegative("weekDayId", weekDayId);

                log.Debug("weekDayId: " + weekDayId + " ");

                // get
                R_WeekDay t = Repository.GetWeekDay(weekDayId);

                WeekDayDTO dto = new WeekDayDTO(t);

                log.Debug(WeekDayDTO.FormatWeekDayDTO(dto));

                return(dto);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Exemplo n.º 3
0
        public int AddWeekDay(WeekDayDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(WeekDayDTO.FormatWeekDayDTO(dto));

                R_WeekDay t = WeekDayDTO.ConvertDTOtoEntity(dto);

                // add
                id            = Repository.AddWeekDay(t);
                dto.WeekDayId = id;

                log.Debug("result: 'success', id: " + id);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }

            return(id);
        }
Exemplo n.º 4
0
        private WeekDayDTO Update(WeekDayViewModel viewModel)
        {
            try
            {
                log.Debug(WeekDayViewModel.FormatWeekDayViewModel(viewModel));

                // get
                log.Debug("_weekDayService.GetWeekDay - weekDayId: " + viewModel.WeekDayId + " ");

                var existingWeekDay = _weekDayService.GetWeekDay(viewModel.WeekDayId);

                log.Debug("_weekDayService.GetWeekDay - " + WeekDayDTO.FormatWeekDayDTO(existingWeekDay));

                if (existingWeekDay != null)
                {
                    // copy values
                    viewModel.UpdateDTO(existingWeekDay, null); //RequestContext.Principal.Identity.GetUserId());

                    // update
                    log.Debug("_weekDayService.UpdateWeekDay - " + WeekDayDTO.FormatWeekDayDTO(existingWeekDay));

                    _weekDayService.UpdateWeekDay(existingWeekDay);

                    log.Debug("result: 'success'");
                }
                else
                {
                    log.Error("existingWeekDay: null, WeekDayId: " + viewModel.WeekDayId);
                }

                return(existingWeekDay);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Exemplo n.º 5
0
        public void DeleteWeekDay(WeekDayDTO dto)
        {
            try
            {
                log.Debug(WeekDayDTO.FormatWeekDayDTO(dto));

                R_WeekDay t = WeekDayDTO.ConvertDTOtoEntity(dto);

                // delete
                Repository.DeleteWeekDay(t);
                dto.IsDeleted = t.IsDeleted;

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Exemplo n.º 6
0
        public void UpdateWeekDay(WeekDayDTO dto)
        {
            try
            {
                //Requires.NotNull(t);
                //Requires.PropertyNotNegative(t, "WeekDayId");

                log.Debug(WeekDayDTO.FormatWeekDayDTO(dto));

                R_WeekDay t = WeekDayDTO.ConvertDTOtoEntity(dto);

                // update
                Repository.UpdateWeekDay(t);

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }