Ejemplo n.º 1
0
        private static GenericResponse UpdatePack(PackInformation pkinfo)
        {
            try
            {
                var response = new GenericResponse();
                using (var context = new Entities())
                {
                    var yd = (from yard in context.Yards
                        where yard.Id == pkinfo.YardId
                        select yard.CustomerNumberPrefix).First() ?? string.Empty;
                    pkinfo.NumberPrefix = yd;
                    pkinfo.InternalPackNumber = yd.Trim() + pkinfo.TagNumber;

                    var pack = (from pk in context.Packs
                        where pk.Id == pkinfo.Id
                        select pk).FirstOrDefault();
                    if (pack == null)
                    {
                        var pk = new Pack();
                        Mapper.Map(pkinfo, pk);
                        context.Packs.AddObject(pk);
                    }
                    else Mapper.Map(pkinfo, pack);
                    context.SaveChanges();
                }
                response.Success = true;
                return response;
            }
            catch (Exception ex)
            {
                LoggingMediator.Log("UpdatePack");
                LoggingMediator.Log(ex);
                return new GenericResponse {Success = false, FailureInformation = "Error in PAPService:UpdatePack"};
            }
        }
Ejemplo n.º 2
0
 private GenericResponse CreatePacksFromXml(IEnumerable<PackReadInformation> packcollection)
 {
     var response = new GenericResponse();
     var userId = Guid.Parse("9BB44614-26C8-4761-BD54-2204E0E76C2D");
     foreach (var pk in packcollection)
     {
         var pack = new PackInformation
                    {
                        Id = Guid.Parse(pk.Id),
                        GrossWeight = Convert.ToDecimal(pk.GrossWeight),
                        TareWeight = Convert.ToDecimal(pk.TareWeight),
                        ScaleGrossWeight = Convert.ToDecimal(pk.ScaleGrossWeight),
                        ScaleTareWeight = Convert.ToDecimal(pk.ScaleTareWeight),
                        TagNumber = Convert.ToInt32(pk.TagNumber),
                        PrintDescription = pk.PrintDescription,
                        UnitOfMeasure = pk.UnitOfMeasure,
                        DateCreated = Convert.ToDateTime(pk.DateCreated),
                        DateClosed = Convert.ToDateTime(pk.DateClosed),
                        Quantity = Convert.ToInt16(pk.Quantity),
                        CommodityType = Convert.ToInt16(pk.CommodityType),
                        PackStatus = Convert.ToInt16(pk.PackStatus),
                        InventoryId = Guid.Parse(pk.InventoryId),
                        YardId = YardId,
                        NumberPrefix = string.Empty,
                        InternalPackNumber = string.Empty,
                        Cost = Convert.ToDecimal(pk.Cost),
                        CreatedByUserId = userId,
                    };
         var pkresponse = UpdatePack(pack);
         if (!pkresponse.Success) response.FailureInformation += pkresponse.FailureInformation;
     }
     return response;
 }