public Entity.DeviceMaintenance Get(Guid id, DateTime currentDate, string timeZone) { List <Entity.DeviceMaintenance> result = new List <Entity.DeviceMaintenance>(); Entity.DeviceMaintenance maintenanceDetail = new Entity.DeviceMaintenance(); try { DateTime dateValue; if (DateTime.TryParse(currentDate.ToString(), out dateValue)) { dateValue = dateValue.AddMinutes(-double.Parse(timeZone)); } logger.InfoLog(Constants.ACTION_ENTRY, "DeviceMaintenanceRepository.GetUpComingList"); using (var sqlDataAccess = new SqlDataAccess(ConnectionString)) { List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, "v1"); parameters.Add(sqlDataAccess.CreateParameter("guid", id, DbType.Guid, ParameterDirection.Input)); parameters.Add(sqlDataAccess.CreateParameter("currentDate", dateValue, DbType.DateTime, ParameterDirection.Input)); DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[DeviceMaintenance_Get]", CommandType.StoredProcedure, null), parameters.ToArray()); result = DataUtils.DataReaderToList <Entity.DeviceMaintenance>(dbDataReader, null); if (result.Count > 0) { maintenanceDetail = result[0]; } } logger.InfoLog(Constants.ACTION_EXIT, "DeviceMaintenanceRepository.GetUpComingList"); } catch (Exception ex) { logger.ErrorLog(Constants.ACTION_EXCEPTION, ex); } return(maintenanceDetail); }
public Entity.DeviceMaintenance Get(Guid id, DateTime currentDate, string timeZone) { Entity.DeviceMaintenance maintenance = new Entity.DeviceMaintenance(); try { maintenance = _deviceMaintenanceRepository.Get(id, currentDate, timeZone); return(maintenance); } catch (Exception ex) { _logger.Error(Constants.ACTION_EXCEPTION, "DeviceMaintenance.Get " + ex); return(null); } }
public Entity.BaseResponse <Entity.DeviceMaintenance> Manage([FromBody] Entity.DeviceMaintenance request) { Entity.BaseResponse <Entity.DeviceMaintenance> response = new Entity.BaseResponse <Entity.DeviceMaintenance>(true); try { var status = _maintenanceService.Manage(request); response.IsSuccess = status.Success; response.Message = status.Message; response.Data = status.Data; } catch (Exception ex) { return(new Entity.BaseResponse <Entity.DeviceMaintenance>(false, ex.Message)); } return(response); }
public Entity.ActionStatus Manage(Entity.DeviceMaintenance request) { Entity.ActionStatus actionStatus = new Entity.ActionStatus(true); try { if (request.Guid == null || request.Guid == Guid.Empty) { var dbDeviceMaintenance = Mapper.Configuration.Mapper.Map <Entity.DeviceMaintenance, Model.DeviceMaintenance>(request); dbDeviceMaintenance.Guid = request.Guid; dbDeviceMaintenance.CompanyGuid = SolutionConfiguration.CompanyId; DateTime dateValue; if (DateTime.TryParse(request.StartDateTime.ToString(), out dateValue)) { dbDeviceMaintenance.StartDateTime = dateValue.AddMinutes(-double.Parse(request.TimeZone)); } if (DateTime.TryParse(request.EndDateTime.ToString(), out dateValue)) { dbDeviceMaintenance.EndDateTime = dateValue.AddMinutes(-double.Parse(request.TimeZone)); } actionStatus = _deviceMaintenanceRepository.Manage(dbDeviceMaintenance); if (actionStatus.Data != null) { dbDeviceMaintenance.Guid = actionStatus.Data; actionStatus.Data = Mapper.Configuration.Mapper.Map <Model.DeviceMaintenance, Entity.DeviceMaintenance>(dbDeviceMaintenance); //Get(actionStatus.Data,DateTime.UtcNow,request.TimeZone); } if (!actionStatus.Success) { _logger.Error($"DeviceMaintenance is not added, Error: {actionStatus.Message}"); actionStatus.Success = false; actionStatus.Message = actionStatus.Message; } } else { var olddbElevatorMaintenance = _deviceMaintenanceRepository.FindBy(x => x.Guid.Equals(request.Guid)).FirstOrDefault(); if (olddbElevatorMaintenance == null) { throw new NotFoundCustomException($"{CommonException.Name.NoRecordsFound} : DeviceMaintenance"); } var dbElevatorMaintenance = Mapper.Configuration.Mapper.Map(request, olddbElevatorMaintenance); dbElevatorMaintenance.CompanyGuid = SolutionConfiguration.CompanyId; DateTime dateValue; double minutes = double.Parse(request.TimeZone); if (DateTime.TryParse(request.StartDateTime.ToString(), out dateValue)) { dbElevatorMaintenance.StartDateTime = dateValue.AddMinutes(-double.Parse(request.TimeZone)); } if (DateTime.TryParse(request.EndDateTime.ToString(), out dateValue)) { dbElevatorMaintenance.EndDateTime = dateValue.AddMinutes(-double.Parse(request.TimeZone)); } actionStatus = _deviceMaintenanceRepository.Manage(dbElevatorMaintenance); if (actionStatus.Data != null) { actionStatus.Data = Mapper.Configuration.Mapper.Map <Model.DeviceMaintenance, Entity.DeviceMaintenance>(dbElevatorMaintenance); } if (!actionStatus.Success) { _logger.Error($"DeviceMaintenance is not updated , Error: {actionStatus.Message}"); actionStatus.Success = false; actionStatus.Message = actionStatus.Message; } } } catch (Exception ex) { _logger.Error(Constants.ACTION_EXCEPTION, "DeviceMaintenanceManager.Delete " + ex); actionStatus.Success = false; actionStatus.Message = ex.Message; } return(actionStatus); }