//HazmatLocation GetLocationByDesc(string desc); public HazmatLocation GetLocationByDesc(string desc) { HazmatLocation location = new HazmatLocation(); // Check if location is of type PS_PAG_LOCATION, if found, it is of type PS_PAG_LOCATION PS_PAG_LOCATION_VW tempLoc1 = context.PS_PAG_LOCATION_VW.Where(l => l.DESCRSHORT == desc).FirstOrDefault(); if (tempLoc1 != null) { location.Address1 = tempLoc1.ADDRESS1.TrimEnd(); location.City = tempLoc1.CITY.TrimEnd(); location.Descr = tempLoc1.DESCR.TrimEnd(); location.DescrShort = tempLoc1.DESCRSHORT.TrimEnd(); location.Location = tempLoc1.LOCATION.TrimEnd(); location.Postal = tempLoc1.POSTAL.TrimEnd(); location.State = tempLoc1.STATE.TrimEnd(); } // Not of type PS_PAG_LOCATION, but instead of type PS_LocationAll if (tempLoc1 == null) { PS_LocationAll tempLoc2 = GetPSLocation(desc); location.Address1 = tempLoc2.ADDRESS1.TrimEnd(); location.City = tempLoc2.CITY.TrimEnd(); location.Descr = tempLoc2.DESCR.TrimEnd(); location.DescrShort = tempLoc2.DESCR.TrimEnd(); location.Location = tempLoc2.LOCATION.TrimEnd(); location.Postal = tempLoc2.POSTAL.ToString(); location.State = tempLoc2.STATE.TrimEnd(); } return(location); }
// public void AddLocation(string descr, string address, string city, string state, string postal) { PS_PAG_LOCATION_VW location = new PS_PAG_LOCATION_VW(); location.LOCATION = descr; location.DESCR = descr; location.DESCRSHORT = descr; location.ADDRESS1 = address; location.CITY = city; location.STATE = state; location.POSTAL = postal; context.PS_PAG_LOCATION_VW.Add(location); }
//PS_PAG_LOCATION_VW GetLocationByOrderNo(string orderNo); public PS_PAG_LOCATION_VW GetLocationByOrderNo(string orderNo) { string locationId = context.HazmatInfoes.Where(o => o.OrderNo == orderNo).Select(l => l.FromBU).SingleOrDefault(); PS_PAG_LOCATION_VW location = context.PS_PAG_LOCATION_VW.Where(l => l.LOCATION == locationId).SingleOrDefault(); location.ADDRESS1 = location.ADDRESS1.TrimEnd(); location.CITY = location.CITY.TrimEnd(); location.DESCR = location.DESCR.TrimEnd(); location.DESCRSHORT = location.DESCRSHORT.TrimEnd(); location.LOCATION = location.LOCATION.TrimEnd(); location.POSTAL = location.POSTAL.TrimEnd(); location.STATE = location.STATE.TrimEnd(); return(location); }
//IEnumerable<PS_PAG_LOCATION_VW> GetReceivers(string shipper); public IEnumerable <PS_PAG_LOCATION_VW> GetShipperReceivers(string shipper) { List <HazmatInfo> pending = GetHazmatInfoPendingShipping().ToList(); List <PS_PAG_LOCATION_VW> receivers = new List <PS_PAG_LOCATION_VW>(); foreach (HazmatInfo item in pending) { string receiverId = item.ToBU; PS_PAG_LOCATION_VW receiver = context.PS_PAG_LOCATION_VW.Where(l => l.LOCATION == receiverId).SingleOrDefault(); if (item.FromBU == shipper) { receiver.ADDRESS1 = receiver.ADDRESS1.TrimEnd(); receiver.CITY = receiver.CITY.TrimEnd(); receiver.DESCR = receiver.DESCR.TrimEnd(); receiver.DESCRSHORT = receiver.DESCRSHORT.TrimEnd(); receiver.LOCATION = receiver.LOCATION.TrimEnd(); receiver.POSTAL = receiver.POSTAL.TrimEnd(); receiver.STATE = receiver.STATE.TrimEnd(); receivers.Add(receiver); } } return(receivers); }