public int Create(TrackingInformation t) { t_id++; t.Id = t_id; trackingInformations.Add(t); return(t.Id); }
public async Task <bool> AddTrackingInformation(TrackingInformation trackingInformation) { try { if (trackingInformation.TrackingId > 0) { var trackingDetails = await _dbContext.InvoiceTrackings.FirstOrDefaultAsync(_ => _.id == trackingInformation.TrackingId); trackingDetails.Comment = trackingInformation.Comment; } else { _dbContext.InvoiceTrackings.Add(new InvoiceTracking { Comment = trackingInformation.Comment, CreatedAt = DateTime.Now, InvoiceId = trackingInformation.InvoiceId, CreatedBy = Convert.ToInt32(SessionHelper.UserTypeId), UserId = Convert.ToInt32(SessionHelper.UserTypeId) }); } await _dbContext.SaveChangesAsync(); } catch { return(false); } return(true); }
public TrackingDetailWindow (TrackingInformation trackingInfo, EventHandler OnSave, Gtk.Window parent) : base(Gtk.WindowType.Toplevel) { this.Build (); this.Modal = true; this.OnSaved = OnSave; this.TransientFor = parent; show.TrackingInfo = trackingInfo; show.IsEditable = false; }
public void GivenTrackingInformationOfLot2003HasDataAsShownInTheTable(string lotNo, Table table) { List<TrackingInformation> lst = new List<TrackingInformation>(); foreach (var row in table.Rows) { TrackingInformation info = new TrackingInformation { TrackingID = Guid.Parse(row["TrackingID"]), Status = row["Status"], LotNo = lotNo, }; lst.Add(info); } _dicLotData[lotNo] = lst; }
public MockTrackingInformationRepository() { var trackInfos = new TrackingInformation[] { new TrackingInformation { Id = 1, State = TrackingInformation.StateEnum.DeliveredEnum }, new TrackingInformation { Id = 2, State = TrackingInformation.StateEnum.InTransportEnum } }; trackingInformations = trackInfos.ToList(); }
public virtual IActionResult TrackParcel([FromRoute] string trackingId) { try { _logger.LogInformation("Calling the TrackParcel action"); TrackingInformation trInfo = _trackingLogic.TrackParcel(trackingId); return(new ObjectResult(trInfo)); } catch (Exception ex) { _logger.LogError("TrackParcel failed", ex); throw new ServiceException("TrackParcel failed", ex); } }
public virtual IActionResult TrackParcel([FromRoute][Required][RegularExpression("^[A-Z0-9]{9}$")] string trackingId) { try { logger.LogInformation($"Tracking Parcel {trackingId}"); Business.Parcel parcel = this.receipientLogic.TrackParcel(trackingId); TrackingInformation p = mapper.Map <TrackingInformation>(parcel); return(StatusCode(200, p)); } catch (BusinessLayerException e) { throw new ServiceLayerException("BL Exception", e); } }
public int Create(TrackingInformation t) { try { _db.Add(t); _db.SaveChanges(); return(t.Id); } catch (SqlException ex) { _logger.LogError(ExceptionHelper.BuildSqlExceptionMessage(ex)); throw new DalException("Could not save tracking information to database", ex); } catch (Exception ex) { _logger.LogError("Could not save tracking information to database", ex); throw new DalException("Could not save tracking information to database", ex); } }
public void Update(TrackingInformation t) { try { var trToUpdate = _db.TrackingInformations.Single(b => b.Id == t.Id); if (trToUpdate != null) { trToUpdate = t; _db.SaveChanges(); } } catch (SqlException ex) { _logger.LogError(ExceptionHelper.BuildSqlExceptionMessage(ex)); throw new DalException("Could not update tracking information", ex); } catch (Exception ex) { _logger.LogError("Could not update tracking information in database", ex); throw new DalException("Could not update tracking information in database", ex); } }
public virtual IActionResult ParcelTrackingIdGet([FromRoute] string trackingId) { _logger.Info("Looking for Parcel with TrackingID: " + trackingId); try { ParcelModel parcelModel = _businessLogic.GetParcelByCode(trackingId); if (parcelModel == null) { return(StatusCode(404, new Error(string.Format("Parcel not found with tracking id '{0}'!", trackingId)))); } TrackingInformationModel trackingInfoModel = _businessLogic.TrackParcel(parcelModel.TrackingCode); TrackingInformation trackingInfo = Mapper.Map <TrackingInformationModel, TrackingInformation>(trackingInfoModel); var response = JsonConvert.SerializeObject(trackingInfo); return(Ok(response)); } catch (Exception ex) { return(StatusCode(500, new Error(ex.Message))); } }
public static void Initialize(DbContext context) { context.Database.EnsureCreated(); // Look for any warehouses if (context.Warehouses.Any()) { return; // DB has been seeded } var recipients = new Recipient[] { new Recipient { FirstName = "Turanga", LastName = "Leela", Street = "Schlagergasse 1", City = "Wien", PostalCode = "A-1090" }, new Recipient { FirstName = "Hubert", LastName = "Farnsworth", Street = "Donatusgasse 2", City = "Linz", PostalCode = "A-4020" } }; foreach (Recipient s in recipients) { context.Recipients.Add(s); } context.SaveChanges(); var trucks = new Truck[] { new Truck { Code = "TR01", Duration = 1m, Latitude = 48.2089816m, Longitude = 16.373213299999975m, Radius = 30m, NumberPlate = "WR-2765" }, //Wien Stephansplatz new Truck { Code = "TR02", Duration = 1m, Latitude = 48.2089816m, Longitude = 16.373213299999975m, Radius = 30m, NumberPlate = "WR-2788" }, //Wien Stephansplatz }; var trucks2 = new Truck[] { new Truck { Code = "TR03", Duration = 1m, Latitude = 48.3059826m, Longitude = 14.287141199999951m, Radius = 30m, NumberPlate = "WR-2777" }, //Linz Hauptplatz new Truck { Code = "TR04", Duration = 1m, Latitude = 48.85661400000001m, Longitude = 2.3522219000000177m, Radius = 30m, NumberPlate = "WR-2739" }, //Paris }; foreach (Truck c in trucks) { context.Trucks.Add(c); } foreach (Truck c in trucks2) { context.Trucks.Add(c); } context.SaveChanges(); var w01 = new Warehouse { Code = "WH01", Description = "Superwarehouse 01", Duration = 2m, Trucks = new List <Truck>(), NextHops = new List <Warehouse>() }; var w02 = new Warehouse { Code = "WH02", Description = "Warehouse 02", Duration = 3m, Trucks = new List <Truck>(), NextHops = new List <Warehouse>() }; var w03 = new Warehouse { Code = "WH03", Description = "Warehouse 03", Duration = 1m, Trucks = trucks.ToList(), NextHops = new List <Warehouse>() }; var w04 = new Warehouse { Code = "WH04", Description = "Warehouse 04", Duration = 2m, Trucks = trucks2.ToList(), NextHops = new List <Warehouse>() }; w01.NextHops.Add(w02); w02.NextHops.Add(w03); w02.NextHops.Add(w04); var warehouses = new Warehouse[] { w01, w02, w03, w04 }; foreach (Warehouse e in warehouses) { context.Warehouses.Add(e); } context.SaveChanges(); var trackingInformations = new TrackingInformation[] { new TrackingInformation { State = TrackingInformation.StateEnum.DeliveredEnum }, new TrackingInformation { State = TrackingInformation.StateEnum.InTransportEnum } }; foreach (TrackingInformation e in trackingInformations) { context.TrackingInformations.Add(e); } context.SaveChanges(); var hopArrivals = new HopArrival[] { new HopArrival { DateTime = DateTime.Parse("2017-11-09"), Code = "WH01", Status = "visited", TrackingInformationId = 1 }, new HopArrival { DateTime = DateTime.Parse("2017-11-10"), Code = "WH02", Status = "visited", TrackingInformationId = 1 }, new HopArrival { DateTime = DateTime.Parse("2017-11-11"), Code = "WH03", Status = "future", TrackingInformationId = 1 }, new HopArrival { DateTime = DateTime.Parse("2017-11-12"), Code = "TR01", Status = "future", TrackingInformationId = 1 }, new HopArrival { DateTime = DateTime.Parse("2018-10-02"), Code = "WH01", Status = "future", TrackingInformationId = 2 }, new HopArrival { DateTime = DateTime.Parse("2018-10-03"), Code = "WH02", Status = "future", TrackingInformationId = 2 }, new HopArrival { DateTime = DateTime.Parse("2018-10-04"), Code = "WH03", Status = "future", TrackingInformationId = 2 }, new HopArrival { DateTime = DateTime.Parse("2018-10-05"), Code = "TR01", Status = "future", TrackingInformationId = 2 }, }; foreach (HopArrival e in hopArrivals) { context.HopArrivals.Add(e); } context.SaveChanges(); var parcels = new Parcel[] { new Parcel { RecipientId = 1, Weight = 22, TrackingNumber = "TN000001", TrackingInformationId = 1 }, new Parcel { RecipientId = 2, Weight = 10, TrackingNumber = "TN000002", TrackingInformationId = 2 }, }; foreach (Parcel e in parcels) { context.Parcels.Add(e); } context.SaveChanges(); }
public override int GetHashCode() => TrackingInformation.GetHashCode() ^ Description.GetHashCode() ^ Delivered.GetHashCode() ^ Weight.GetHashCode() ^ Status.GetHashCode();
public void Update(TrackingInformation t) { TrackingInformation t2 = trackingInformations.Find(item => item.Id == t.Id); t = t2; }
public void Delete(int id) { TrackingInformation t = trackingInformations.SingleOrDefault(item => item.Id == id); trackingInformations.Remove(t); }