public static void SaveGrn(Grn grn) { using (RetailDbContext retailDbContext = new RetailDbContext()) { retailDbContext.Grns.Add(grn); retailDbContext.SaveChanges(); //This will give us a unique GrnID //QtyOnHand change foreach (Grnline gl in grn.Grnlines) { StoreProduct storeProduct = retailDbContext.StoreProducts.ToList().SingleOrDefault <StoreProduct>(x => (x.ProductID == gl.ProductID) && (x.StoreID == grn.StoreID)); if (storeProduct == null) { storeProduct = new StoreProduct(); storeProduct.ProductID = gl.ProductID; storeProduct.StoreID = grn.StoreID; storeProduct.QtyOnHand += gl.Quantity; retailDbContext.StoreProducts.Add(storeProduct); } else { storeProduct.QtyOnHand += gl.Quantity; } StoreProductTran storeProductTran = new StoreProductTran(); storeProductTran.ProductID = storeProduct.ProductID; storeProductTran.DocumentType = "G"; storeProductTran.DocumentID = grn.GrnID; storeProductTran.Quantity = gl.Quantity; storeProductTran.EffectiveTime = grn.TransactionTime; retailDbContext.StoreProductTrans.Add(storeProductTran); } retailDbContext.SaveChanges(); } }
public async Task <IHttpActionResult> PutGrn(int id, Grn grn) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != grn.Id) { return(BadRequest()); } db.Entry(grn).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GrnExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void UploadGrn(Grn g) { Task taskA = Task.Factory.StartNew(() => { PosWebService.PosWebServiceClient client = new PosWebService.PosWebServiceClient(); client.UploadGrn(g); }); }
public void FinaliseGrn(Grn g) { g.TransactionTime = DateTime.Now; DBRepository.SaveGrn(g); //Replicate to HODB using WCF service in a TPL task UploadGrn(g); }
public async Task <IHttpActionResult> GetGrn(int id) { Grn grn = await db.Grns.FindAsync(id); if (grn == null) { return(NotFound()); } return(Ok(grn)); }
public async Task <IHttpActionResult> PostGrn([FromBody] Grn datas) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Grns.Add(datas); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = datas.Id }, datas)); }
public async Task <IHttpActionResult> DeleteGrn(int id) { Grn grn = await db.Grns.FindAsync(id); if (grn == null) { return(NotFound()); } db.Grns.Remove(grn); await db.SaveChangesAsync(); return(Ok(grn)); }
public XtraReport GenerateReport(NameValueCollection parameters) { var grnReport = new Grn(); var grnReportData = AsyncContext.Run(() => _reportService.GetGrnReport(long.Parse(parameters["id"]))); var grnObjectDataSource = new ObjectDataSource { DataSource = grnReportData, Name = "GrnDataSource" }; grnReport.DataSource = grnObjectDataSource; return(grnReport); }
public void UploadGrn(Grn grn) { DBRepository.SaveGrn(grn); }
public ActionResult FinaliseGrn(Grn grn) { rm.FinaliseGrn(grn); return(View("Index", rm)); }
public GrnVM() { TheEntity = new Grn(); }