private GenericResponse CreatePackListsFromXml(IEnumerable<PackListReadInformation> listcollection)
        {
            var response = new GenericResponse();
            var userId = Guid.Parse("9BB44614-26C8-4761-BD54-2204E0E76C2D");
            using (var context = new Entities())
            {
                foreach (var pl in listcollection)
                {
                    var isTransfer = context.TransferSentHeads.FirstOrDefault(trans => trans.Id == Guid.Parse(pl.ContractId)) != null;
                    var plist = new PackListInformation
                                {
                                    Id = Guid.Parse(pl.PackListId),
                                    ContractHeadId = isTransfer?Guid.Empty:Guid.Parse(pl.ContractId),
                                    TransferSentHeadId = isTransfer ? Guid.Parse(pl.ContractId):Guid.Empty,
                                    CreatedByUserId = userId,
                                    PackListNumber = Convert.ToInt32(pl.PackListNumber),
                                    DateCreated = DateTime.Now,
                                    SealNumber = string.Empty,
                                    Units = 0,
                                    PackListStatus = (int) PackListStatus.Held,
                                };
                    var pkresponse = isTransfer?UpdateTransferPackList(plist):UpdatePackList(plist);
                    if (!pkresponse.Success) response.FailureInformation += pkresponse.FailureInformation;
                }
            }

            return response;
        }
 private static GenericResponse UpdateTransferPackList(PackListInformation listinfo)
 {
     try
     {
         var response = new GenericResponse();
         using (var context = new Entities())
         {
             var plist = (from list in context.TransferPackListHeads
                          where list.Id == listinfo.Id
                          select list).FirstOrDefault();
             if (plist == null)
             {
                 var list = new TransferPackListHead();
                 Mapper.Map(listinfo, list);
                 context.TransferPackListHeads.AddObject(list);
             }
             else Mapper.Map(listinfo, plist);
             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:UpdateTransferPackList"};
     }
 }