// POST api/<controller>
        public async Task Post(PrLinesViewModel value)
        {
            var nh   = new NHibernateUserStore();
            var nhps = new NHibernatePRStore();
            var nhcs = new NHibernateNonCatalogStore();
            var user = nh.FindByStampAsync(value.SecurityStamp);

            if (user != null)
            {
                var       nhis = new NHibernateItemStore();
                ItemModel item = null;
                NonCatalogItemHeadModel nonCatalog = null;
                if (value.itemType == "Catalog")
                {
                    item = await nhis.FindItemByIdAsync(value.Id);
                }
                else
                {
                    nonCatalog = await nhcs.GetNonCatalogAsync(value.Id);
                }
                var PrLines = new PRLinesModel {
                    Item       = item,
                    NonCatalog = nonCatalog,
                    Quantity   = value.Quantity,
                    CreatedBy  = user.Result
                };
                try {
                    await nhps.CreatePRLinesAsync(PrLines);
                } catch (Exception e) {
                    var a = e.Message;
                }
            }
        }
 public async Task <IList <POHeaderModel> > FindPoWithSameSupplierAsync(PRLinesModel prLine)
 {
     using (var db = HibernateSession.GetCurrentSession()) {
         using (var tx = db.BeginTransaction()) {
             return(db.QueryOver <POHeaderModel>().Where(x => x.DeleteTime == null && x.Status == StatusType.Saved &&
                                                         x.Supplier == prLine.Supplier && x.CRC == prLine.Header.CRC).List());
         }
     }
 }
Esempio n. 3
0
 public async Task CreatePRLinesAsync(PRLinesModel line)
 {
     using (var db = HibernateSession.GetCurrentSession()) {
         using (var tx = db.BeginTransaction()) {
             db.Save(line);
             tx.Commit();
             db.Flush();
         }
     }
 }