public Entity.BaseResponse <Entity.ElevatorMaintenance> Manage([FromBody] Entity.ElevatorMaintenance request)
 {
     Entity.BaseResponse <Entity.ElevatorMaintenance> response = new Entity.BaseResponse <Entity.ElevatorMaintenance>(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.ElevatorMaintenance>(false, ex.Message));
     }
     return(response);
 }
 public Entity.ElevatorMaintenance Get(Guid id)
 {
     Entity.ElevatorMaintenance maintenance = new Entity.ElevatorMaintenance();
     try
     {
         maintenance = _elevatorMaintenanceRepository.FindBy(t => t.Guid == id).Select(p => Mapper.Configuration.Mapper.Map <Entity.ElevatorMaintenance>(p)).FirstOrDefault();
         if (maintenance != null)
         {
             maintenance.BuildingGuid = _entityRepository.FindBy(t => t.Guid == maintenance.EntityGuid).FirstOrDefault().ParentEntityGuid;
         }
         return(maintenance);
     }
     catch (Exception ex)
     {
         _logger.Error(Constants.ACTION_EXCEPTION, "ElevatorMaintenance.Get " + ex);
         return(null);
     }
 }
        public Entity.ActionStatus Manage(Entity.ElevatorMaintenance request)
        {
            Entity.ActionStatus actionStatus = new Entity.ActionStatus(true);
            try
            {
                if (request.Guid == null || request.Guid == Guid.Empty)
                {
                    var dbElevatorMaintenance = Mapper.Configuration.Mapper.Map <Entity.ElevatorMaintenance, Model.ElevatorMaintenance>(request);

                    dbElevatorMaintenance.Guid        = request.Guid;
                    dbElevatorMaintenance.CompanyGuid = SolutionConfiguration.CompanyId;
                    DateTime dateValue;
                    if (DateTime.TryParse(request.ScheduledDate.ToString(), out dateValue))
                    {
                        dbElevatorMaintenance.ScheduledDate = dateValue;
                    }

                    actionStatus = _elevatorMaintenanceRepository.Manage(dbElevatorMaintenance);
                    if (actionStatus.Data != null)
                    {
                        //   actionStatus.Data = Mapper.Configuration.Mapper.Map<Model.ElevatorMaintenance, Entity.ElevatorMaintenance>(actionStatus.Data);
                        actionStatus.Data = Get(actionStatus.Data);
                    }
                    if (!actionStatus.Success)
                    {
                        _logger.Error($"ElevatorMaintenance is not added, Error: {actionStatus.Message}");
                        actionStatus.Success = false;
                        actionStatus.Message = actionStatus.Message;
                    }
                }
                else
                {
                    var olddbElevatorMaintenance = _elevatorMaintenanceRepository.FindBy(x => x.Guid.Equals(request.Guid)).FirstOrDefault();
                    if (olddbElevatorMaintenance == null)
                    {
                        throw new NotFoundCustomException($"{CommonException.Name.NoRecordsFound} : ElevatorMaintenance");
                    }
                    var dbElevatorMaintenance = Mapper.Configuration.Mapper.Map(request, olddbElevatorMaintenance);
                    dbElevatorMaintenance.CompanyGuid = SolutionConfiguration.CompanyId;

                    actionStatus = _elevatorMaintenanceRepository.Manage(dbElevatorMaintenance);
                    if (actionStatus.Data != null)
                    {
                        actionStatus.Data = Mapper.Configuration.Mapper.Map <Model.ElevatorMaintenance, Entity.ElevatorMaintenance>(dbElevatorMaintenance);
                    }
                    if (!actionStatus.Success)
                    {
                        _logger.Error($"ElevatorMaintenance is not updated , Error: {actionStatus.Message}");
                        actionStatus.Success = false;
                        actionStatus.Message = actionStatus.Message;
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(Constants.ACTION_EXCEPTION, "ElevatorMaintenanceManager.Delete " + ex);
                actionStatus.Success = false;
                actionStatus.Message = ex.Message;
            }
            return(actionStatus);
        }