// GET: Stocks/Edit/5 public async Task <ActionResult> Edit(string id) { var stock = await StockLib.GetStock(id.ToString()); if (stock == null) { var errorMsg = string.Format("Stock {0} not found.", id); throw new HttpException(404, errorMsg); } return(View(stock)); }
public async Task <ActionResult> DeleteConfirmed(string id) { try { await StockLib.DeleteStock(id); return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Ticker")] Stock stock) { try { //var stockName = collection["StockName"].ToString(); //var stock = new Stock() //{ // Id = id, // StockName = stockName //}; await StockLib.UpdateStock(stock); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
private static StockEntry CreateStockEntry(StockXmlRow xml, StockLib parent) { return(new StockEntry() { StockLibraryIndex = parent, Batch = xml.Batch.NotAvailable(), Blocked = xml.Blocked, InQualityInsp = xml.InQualityInsp, IPRType = false, StorLoc = xml.SLoc.NotAvailable(), RestrictedUse = xml.RestrictedUse, SKU = xml.Material.NotAvailable(), Title = xml.MaterialDescription.NotAvailable(), Units = xml.BUn.NotAvailable(), Unrestricted = xml.Unrestricted, BatchIndex = null, ProductType = ProductType.Invalid, Quantity = xml.Blocked + xml.InQualityInsp + xml.RestrictedUse + xml.Unrestricted, }); }
/// <summary> /// Iports the stock from XML. /// </summary> /// <param name="stream">The stream.</param> /// <param name="url">The URL.</param> /// <param name="listIndex">Index of the list.</param> /// <param name="fileName">Name of the file.</param> /// <param name="progressChanged">The progress changed.</param> public static void IportStockFromXML(Stream stream, string url, int listIndex, string fileName, ProgressChangedEventHandler progressChanged) { try { using (Entities _edc = new Entities(url)) { String _message = String.Format("Import of the stock message {0} starting.", fileName); ActivityLogCT.WriteEntry(_edc, m_Source, _message); StockXml document = StockXml.ImportDocument(stream); StockLib _entry = Element.GetAtIndex <StockLib>(_edc.StockLibrary, listIndex); _entry.Stock2JSOXLibraryIndex = null; ErrorsList _warnings = new ErrorsList(); IportXml(document, _edc, _entry, _warnings, progressChanged); InputDataValidationException _exc = new InputDataValidationException("there are errors in the stockm XML message.", "GetBatchLookup", _warnings); switch (_exc.Valid) { case InputDataValidationException.Result.Success: break; case InputDataValidationException.Result.Warnings: _exc.ReportActionResult(url, fileName); break; case InputDataValidationException.Result.FatalErrors: throw _exc; } progressChanged(null, new ProgressChangedEventArgs(1, "Submitting Changes - Warnings")); _edc.SubmitChanges(); } } catch (WebsiteModel.InputDataValidationException _iove) { _iove.ReportActionResult(url, fileName); ActivityLogCT.WriteEntry(m_Source, String.Format("Import of the stock message {0} failed.", fileName), url); } catch (Exception ex) { ActivityLogCT.WriteEntry("Stock XML message import fatal error", ex.Message, url); } ActivityLogCT.WriteEntry(m_Source, String.Format("Import of the stock message {0} finished.", fileName), url); }
private static void IportXml(StockXml document, Entities edc, StockLib parent, ErrorsList _warnings, ProgressChangedEventHandler progressChanged) { List <StockEntry> stockEntities = new List <StockEntry>(); foreach (StockXmlRow _row in document.Row) { try { StockEntry nse = CreateStockEntry(_row, parent); nse.ProcessEntry(edc, _warnings); progressChanged(_row, new ProgressChangedEventArgs(1, _row.Material)); stockEntities.Add(nse); } catch (Exception ex) { _warnings.Add(new Warnning(String.Format("Stock entry {1} fatal import error: {0}", ex.ToString(), _row.MaterialDescription), true)); } } if (stockEntities.Count > 0) { edc.StockEntry.InsertAllOnSubmit(stockEntities); } }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,Ticker")] Stock stock) { try { var rand = new Random(); var id = rand.Next().ToString(); stock.Id = id; //var stockName = collection["StockName"].ToString(); //var symbol = co //var stock = new Stock() //{ // Id = id, // Name = stockName, // Symbol //}; await StockLib.InsertStock(stock); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
// GET: Stocks public async Task <ActionResult> Index() { var stocks = await StockLib.GetAllStocks(); return(View(stocks)); }