示例#1
0
        public ProgramStepDto GetStep(Guid id)
        {
            ProgramStep programStep;

            try
            {
                programStep = _robotProgramBusinessLogic.GetStep(id);
            }
            catch (ArgumentException ex)
            {
                this.Log.Error(LogHelper.GetMethodInfoErrorMessage(MethodBase.GetCurrentMethod(), id), ex);

                var fault = new EntityNotFoundFault
                {
                    Message    = "Step program not found",
                    EntityName = typeof(ProgramStep).Name
                };

                throw new FaultException <EntityNotFoundFault>(fault);
            }

            ProgramStepDto stepDto = Mapper.Map <ProgramStepDto>(programStep);

            return(stepDto);
        }
        public void UpdateStep(ProgramStepViewModel step)
        {
            try
            {
                ProgramStepDto stepDto = Mapper.Map <ProgramStepDto>(step);

                _robotProgramService.UpdateStep(stepDto);
            }
            catch (FaultException ex)
            {
                throw new HttpException((int)HttpStatusCode.InternalServerError, "Error occured while updating step", ex);
            }
        }
 public ProgramStepViewModel GetStep(Guid id)
 {
     try
     {
         ProgramStepDto step = _robotProgramService.GetStep(id);
         return(Mapper.Map <ProgramStepViewModel>(step));
     }
     catch (FaultException <EntityNotFoundFault> ex)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, ex.Message, ex);
     }
     catch (FaultException ex)
     {
         throw new HttpException((int)HttpStatusCode.InternalServerError, $"Error occured while getting step {id}", ex);
     }
 }
示例#4
0
        public void UpdateStep(ProgramStepDto step)
        {
            if (step == null)
            {
                var fault = new ArgumentFault
                {
                    Message      = "Argumnet is null",
                    ArgumentName = nameof(step)
                };

                throw new FaultException <ArgumentFault>(fault);
            }

            ProgramStep stepEntity = Mapper.Map <ProgramStep>(step);

            _robotProgramBusinessLogic.UpdateStep(stepEntity);
        }
示例#5
0
        public void AddStep(ProgramStepDto step)
        {
            // TODO: null-possibility should rather be checked in Buisness logic, and here just try-catch-toFaultConv
            if (step == null)
            {
                var fault = new ArgumentFault
                {
                    Message      = "Argumnet is null",
                    ArgumentName = nameof(step)
                };

                throw new FaultException <ArgumentFault>(fault);
            }

            ProgramStep stepEntity = Mapper.Map <ProgramStep>(step);

            _robotProgramBusinessLogic.AddStep(stepEntity);
        }