public override Result <List <MemberModel> > FindAll(IFilter filter) { try { var filterImpl = (MemberFilter)filter; var members = _memberDAL.FindAll(filterImpl); var memberModels = _mapper.Map <List <MemberModel> >(members); return(Result <List <MemberModel> > .BuildSuccess(memberModels)); } catch (Exception error) { return(Result <List <MemberModel> > .BuildError("Erro ao localizar o membro.", error)); } }
public Result SendVehicle(ServiceHistoryModel serviceHistoryModel) { try { var vehicleRequerid = _emergencyRequiredVehicleDAL.Find(new EmergencyRequiredVehicleFilter { Id = serviceHistoryModel.EmergencyRequiredVehicleId }); vehicleRequerid.Status = VehicleRequiredStatus.Committed; vehicleRequerid.Emergency.EmergencyStatus = EmergencyStatus.Committed; _emergencyRequiredVehicleDAL.Update(vehicleRequerid); var vehicle = _vehicleDAL.Find(new VehicleFilter { Id = serviceHistoryModel.VehicleId }); vehicle.VehicleStatus = VehicleStatus.InService; _vehicleDAL.Update(vehicle); var serviceHistory = new ServiceHistory { EmergencyId = vehicleRequerid.EmergencyId, Description = "Veículo empenhado", Date = serviceHistoryModel.Date, ServiceHistoryStatus = ServiceHistoryStatus.InProgress, VehicleId = serviceHistoryModel.VehicleId, CodeColor = vehicleRequerid.CodeColor }; _serviceHistoryDAL.Insert(serviceHistory); var members = _memberDAL.FindAll(new MemberFilter { EmployeeStatus = EmployeeStatus.Working, VehicleId = vehicle.Id }); members.ForEach(d => { var teamMember = new TeamMember { MemberId = d.Id, ServiceHistory = serviceHistory }; _teamMemberDAL.Insert(teamMember); }); var resultSave = _serviceHistoryDAL.Save(); return(resultSave); } catch (Exception error) { return(Result.BuildError("Erro ao enviar veículo, favor tente novamente.", error)); } }