public RobotProgramDto GetProgram(Guid id) { RobotProgram robotProgram; try { robotProgram = _robotProgramBusinessLogic.GetProgram(id); } catch (ArgumentException ex) { this.Log.Error(LogHelper.GetMethodInfoErrorMessage(MethodBase.GetCurrentMethod(), id), ex); var fault = new EntityNotFoundFault { Message = "Robot program not found", EntityName = typeof(RobotProgram).Name }; throw new FaultException <EntityNotFoundFault>(fault); } RobotProgramDto programDto = Mapper.Map <RobotProgramDto>(robotProgram); return(programDto); }
public void UpdateProgram(RobotProgramViewModel program) { try { RobotProgramDto programDto = Mapper.Map <RobotProgramDto>(program); _robotProgramService.UpdateProgram(programDto); } catch (FaultException ex) { throw new HttpException((int)HttpStatusCode.InternalServerError, "Error occured while updating program", ex); } }
public RobotProgramViewModel GetProgram(Guid id) { try { RobotProgramDto program = _robotProgramService.GetProgram(id); return(Mapper.Map <RobotProgramViewModel>(program)); } 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 program {id}", ex); } }
public void UpdateProgram(RobotProgramDto program) { if (program == null) { var fault = new ArgumentFault { Message = "Argumnet is null", ArgumentName = nameof(program) }; throw new FaultException <ArgumentFault>(fault); } RobotProgram programEntity = Mapper.Map <RobotProgram>(program); _robotProgramBusinessLogic.UpdateProgram(programEntity); }