public async Task <string> UpdateLineitemsAsync([FromBody] string value) { string NewInsertionID = "0"; try { PurchaseOrderLineItems newPOlineitems = JsonConvert.DeserializeObject <PurchaseOrderLineItems>(value); NewInsertionID = await _ProductRepo.UpdatePoLineItems(newPOlineitems); var qty = 0; if (newPOlineitems.originalQty > newPOlineitems.line_item_ordered_quantity) { qty = newPOlineitems.originalQty - newPOlineitems.line_item_ordered_quantity; } else { qty = newPOlineitems.line_item_ordered_quantity - newPOlineitems.originalQty; } //Updattion // Increase/Decrease Line Style Qty in calculation against PO for style Qty var _check = await _CalculationValuesRepo.CreateProductCalculation(newPOlineitems.po_id.ToString(), 5, qty, newPOlineitems.IsQtyIncreased); } catch (Exception ex) { var logger = _loggerFactory.CreateLogger("internal_error_log"); logger.LogInformation("Problem happened in making new line items with message" + ex.Message); } return(NewInsertionID); }
/*Developer: ubaid * Date:5-7-19 * Action:get PurchaseOrderLineItems Model from controller and insert the PurchaseOrderLineItems * Input: PurchaseOrderLineItems Model * output: New PO LineItem id */ public async Task <string> CreatePOLineitems(PurchaseOrderLineItems NewLineitem) { using (IDbConnection conn = Connection) { var result = await conn.InsertAsync <PurchaseOrderLineItems>(NewLineitem); return(result.ToString()); } }
/* * Developer: Sajid Khan * Date: 7-5-19 * Action: update purchase order line item data by id from database * Input: purchase order line item data * output: Boolean */ public async Task <Boolean> Update(PurchaseOrderLineItems PoLineItemToUpdate) { using (IDbConnection conn = Connection) { var result = await conn.UpdateAsync <PurchaseOrderLineItems>(PoLineItemToUpdate); return(result); } }
public async Task <List <PurchaseOrderLineItems> > GetAsync(int id) { List <PurchaseOrderLineItems> ToReturn = new List <PurchaseOrderLineItems>(); try { PurchaseOrderLineItems Res = await _PurchaseOrdersLineItemsRepo.GetById(id); ToReturn.Add(Res); } catch (Exception ex) { var logger = _loggerFactory.CreateLogger("internal_error_log"); logger.LogInformation("Problem happened in selecting the data for GetAsync with message" + ex.Message); } return(ToReturn); }
/*Developer: Hamza Haq * Date:31-8-19 * Action:get PurchaseOrderLineItems Model from controller and Update the PurchaseOrderLineItems * Input: PurchaseOrderLineItems Model * output: old PO LineItem id */ public async Task <string> UpdatePoLineItems(PurchaseOrderLineItems NewLineitem) { using (IDbConnection conn = Connection) { String updateQuery = ""; if (NewLineitem.line_item_id == 0) { updateQuery = "update purchase_order_line_items set line_item_ordered_quantity = " + NewLineitem.line_item_ordered_quantity + " , updated_by = " + NewLineitem.updated_by + " , updated_at = " + NewLineitem.updated_at + " where vendor_id='" + NewLineitem.vendor_id + "' and sku='" + NewLineitem.sku + "' and po_id = " + NewLineitem.po_id; } else { updateQuery = "update purchase_order_line_items set line_item_ordered_quantity = " + NewLineitem.line_item_ordered_quantity + " , updated_by = " + NewLineitem.updated_by + " , updated_at = " + NewLineitem.updated_at + " where line_item_id=" + NewLineitem.line_item_id + ""; } var result = await conn.QueryAsync(updateQuery); return(result.ToString()); } }
public async Task <string> Update(int id, [FromBody] string value) { string UpdateResult = "Success"; bool UpdateProcessOutput = false; try { PurchaseOrderLineItems PoLineItemToUpdate = JsonConvert.DeserializeObject <PurchaseOrderLineItems>(value); PoLineItemToUpdate.line_item_id = id; UpdateProcessOutput = await _PurchaseOrdersLineItemsRepo.Update(PoLineItemToUpdate); var eventModel = new EventModel(tableName) { EntityId = PoLineItemToUpdate.po_id, EventName = po_lineitem_update, RefrenceId = id, UserId = PoLineItemToUpdate.updated_by, EventNoteId = id }; await _eventRepo.AddEventAsync(eventModel); var userEvent = new EventModel(userEventTableName) { EntityId = PoLineItemToUpdate.updated_by, EventName = po_lineitem_update, RefrenceId = id, UserId = PoLineItemToUpdate.updated_by, EventNoteId = id }; await _eventRepo.AddEventAsync(userEvent); } catch (Exception ex) { var logger = _loggerFactory.CreateLogger("internal_error_log"); logger.LogInformation("Problem happened in updating attribute with message" + ex.Message); UpdateResult = "Failed"; } if (!UpdateProcessOutput) { UpdateResult = "Creation failed due to reason: No specific reson"; } return(UpdateResult); }
public async Task <string> PostAsyncLineitem([FromBody] string value) { string NewInsertionID = "0"; try { PurchaseOrderLineItems newPOlineitems = JsonConvert.DeserializeObject <PurchaseOrderLineItems>(value); NewInsertionID = await _ProductRepo.CreatePOLineitems(newPOlineitems); // Add Line Style Qty in calculation against PO for style Qty var _check = await _CalculationValuesRepo.CreateProductCalculation(newPOlineitems.po_id.ToString(), 5, newPOlineitems.line_item_ordered_quantity, true); } catch (Exception ex) { var logger = _loggerFactory.CreateLogger("internal_error_log"); logger.LogInformation("Problem happened in making new line items with message" + ex.Message); } return(NewInsertionID); }
public async Task <string> PostAsync([FromBody] string value) { string NewInsertionID = "0"; try { PurchaseOrderLineItems NewPoLineItem = JsonConvert.DeserializeObject <PurchaseOrderLineItems>(value); NewInsertionID = await _PurchaseOrdersLineItemsRepo.Create(NewPoLineItem); var eventModel = new EventModel(tableName) { EntityId = NewPoLineItem.po_id, EventName = po_lineitem_created, RefrenceId = Int32.Parse(NewInsertionID), UserId = NewPoLineItem.created_by, EventNoteId = Convert.ToInt32(NewInsertionID) }; await _eventRepo.AddEventAsync(eventModel); var userEvent = new EventModel(userEventTableName) { EntityId = NewPoLineItem.created_by, EventName = po_lineitem_created, RefrenceId = Convert.ToInt32(NewInsertionID), UserId = NewPoLineItem.created_by, EventNoteId = Convert.ToInt32(NewInsertionID) }; await _eventRepo.AddEventAsync(userEvent); } catch (Exception ex) { var logger = _loggerFactory.CreateLogger("internal_error_log"); logger.LogInformation("Problem happened in making new attribute with message" + ex.Message); } return(NewInsertionID); }
public async Task <string> UpdateSpecific(int id, [FromBody] string value) { string UpdateResult = "Success"; try { PurchaseOrderLineItems PoLineItemToUpdate = JsonConvert.DeserializeObject <PurchaseOrderLineItems>(value); PoLineItemToUpdate.line_item_id = id; Dictionary <String, String> ValuesToUpdate = new Dictionary <string, string>(); if (PoLineItemToUpdate.po_id != 0) { ValuesToUpdate.Add("po_id", PoLineItemToUpdate.po_id.ToString()); } if (PoLineItemToUpdate.vendor_id != 0) { ValuesToUpdate.Add("vendor_id", PoLineItemToUpdate.vendor_id.ToString()); } if (PoLineItemToUpdate.sku != null) { ValuesToUpdate.Add("sku", PoLineItemToUpdate.sku); } if (PoLineItemToUpdate.product_id != 0) { ValuesToUpdate.Add("product_id", PoLineItemToUpdate.product_id.ToString()); } if (PoLineItemToUpdate.line_item_cost != 0) { ValuesToUpdate.Add("line_item_cost", PoLineItemToUpdate.line_item_cost.ToString()); } if (PoLineItemToUpdate.line_item_retail != 0) { ValuesToUpdate.Add("line_item_retail", PoLineItemToUpdate.line_item_retail.ToString()); } if (PoLineItemToUpdate.line_item_type != 0) { ValuesToUpdate.Add("line_item_type", PoLineItemToUpdate.line_item_type.ToString()); } if (PoLineItemToUpdate.line_item_ordered_quantity >= 0) { ValuesToUpdate.Add("line_item_ordered_quantity", PoLineItemToUpdate.line_item_ordered_quantity.ToString()); } if (PoLineItemToUpdate.line_item_accepted_quantity != 0) { ValuesToUpdate.Add("line_item_accepted_quantity", PoLineItemToUpdate.line_item_accepted_quantity.ToString()); } if (PoLineItemToUpdate.line_item_rejected_quantity != 0) { ValuesToUpdate.Add("line_item_rejected_quantity", PoLineItemToUpdate.line_item_rejected_quantity.ToString()); } if (PoLineItemToUpdate.updated_by != 0) { ValuesToUpdate.Add("updated_by", PoLineItemToUpdate.updated_by.ToString()); } if (PoLineItemToUpdate.updated_at != 0) { ValuesToUpdate.Add("updated_at", PoLineItemToUpdate.updated_at.ToString()); } await _PurchaseOrdersLineItemsRepo.UpdateSpecific(ValuesToUpdate, "line_item_id=" + id); var eventModel = new EventModel(tableName) { EntityId = PoLineItemToUpdate.po_id, EventName = po_lineitem_specific_update, RefrenceId = id, UserId = PoLineItemToUpdate.updated_by, EventNoteId = id }; await _eventRepo.AddEventAsync(eventModel); var userEvent = new EventModel(userEventTableName) { EntityId = PoLineItemToUpdate.updated_by, EventName = po_lineitem_specific_update, RefrenceId = id, UserId = PoLineItemToUpdate.updated_by, EventNoteId = id }; await _eventRepo.AddEventAsync(userEvent); } catch (Exception ex) { var logger = _loggerFactory.CreateLogger("internal_error_log"); logger.LogInformation("Problem happened in updating new attribute with message" + ex.Message); UpdateResult = "Failed"; } return(UpdateResult); }
public static PurchaseOrderLineItems CreatePurchaseOrderLineItems(long purchaseOrderLineItemID) { PurchaseOrderLineItems purchaseOrderLineItems = new PurchaseOrderLineItems(); purchaseOrderLineItems.PurchaseOrderLineItemID = purchaseOrderLineItemID; return purchaseOrderLineItems; }
public void AddToPurchaseOrderLineItems(PurchaseOrderLineItems purchaseOrderLineItems) { base.AddObject("PurchaseOrderLineItems", purchaseOrderLineItems); }