Esempio n. 1
0
        private CheckpointDTO Create(CheckpointViewModel viewModel)
        {
            try
            {
                log.Debug(CheckpointViewModel.FormatCheckpointViewModel(viewModel));

                CheckpointDTO checkpoint = new CheckpointDTO();

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

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

                // add
                log.Debug("_checkpointService.AddCheckpoint - " + CheckpointDTO.FormatCheckpointDTO(checkpoint));

                int id = _checkpointService.AddCheckpoint(checkpoint);

                checkpoint.CheckpointId = id;

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

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

                throw;
            }
        }
Esempio n. 2
0
        public CheckpointDTO GetCheckpoint(int checkpointId)
        {
            try
            {
                //Requires.NotNegative("checkpointId", checkpointId);

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

                // get
                R_Checkpoint t = Repository.GetCheckpoint(checkpointId);

                CheckpointDTO dto = new CheckpointDTO(t);

                log.Debug(CheckpointDTO.FormatCheckpointDTO(dto));

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

                throw;
            }
        }
Esempio n. 3
0
        public int AddCheckpoint(CheckpointDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(CheckpointDTO.FormatCheckpointDTO(dto));

                R_Checkpoint t = CheckpointDTO.ConvertDTOtoEntity(dto);

                // add
                id = Repository.AddCheckpoint(t);
                dto.CheckpointId = id;

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

                throw;
            }

            return(id);
        }
Esempio n. 4
0
        private CheckpointDTO Update(CheckpointViewModel viewModel)
        {
            try
            {
                log.Debug(CheckpointViewModel.FormatCheckpointViewModel(viewModel));

                // get
                log.Debug("_checkpointService.GetCheckpoint - checkpointId: " + viewModel.CheckpointId + " ");

                var existingCheckpoint = _checkpointService.GetCheckpoint(viewModel.CheckpointId);

                log.Debug("_checkpointService.GetCheckpoint - " + CheckpointDTO.FormatCheckpointDTO(existingCheckpoint));

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

                    // update
                    log.Debug("_checkpointService.UpdateCheckpoint - " + CheckpointDTO.FormatCheckpointDTO(existingCheckpoint));

                    _checkpointService.UpdateCheckpoint(existingCheckpoint);

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

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

                throw;
            }
        }
Esempio n. 5
0
        public void DeleteCheckpoint(CheckpointDTO dto)
        {
            try
            {
                log.Debug(CheckpointDTO.FormatCheckpointDTO(dto));

                R_Checkpoint t = CheckpointDTO.ConvertDTOtoEntity(dto);

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

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

                throw;
            }
        }
Esempio n. 6
0
        public void UpdateCheckpoint(CheckpointDTO dto)
        {
            try
            {
                //Requires.NotNull(t);
                //Requires.PropertyNotNegative(t, "CheckpointId");

                log.Debug(CheckpointDTO.FormatCheckpointDTO(dto));

                R_Checkpoint t = CheckpointDTO.ConvertDTOtoEntity(dto);

                // update
                Repository.UpdateCheckpoint(t);

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

                throw;
            }
        }