public ActionResult _Create(StockCreateViewModel model) { StockLiabilityListCreateViewModel liabilities = (StockLiabilityListCreateViewModel)HttpContext.Session["LIABILITIES"]; double totalLiabilityValue = 0; if (liabilities != null) { totalLiabilityValue = liabilities.Liabilities.Sum(x => x.Value.HasValue ? x.Value.Value : 0); } if (model.StockValue < totalLiabilityValue && totalLiabilityValue > 0) { ModelState.AddModelError("CompareStockValueAndLiabilityValue", "Giá trị tổng số nợ không vượt quá giá trị cổ phiếu"); } if (StockQueries.CheckExistStock(UserQueries.GetCurrentUsername(), model.Name)) { ModelState.AddModelError("DuplicateName", "Cổ phiếu này đã tồn tại"); } if (ModelState.IsValid) { HttpContext.Session["STOCK"] = model; return(Content("success")); } else { return(PartialView("_StockForm", model)); } }
public ActionResult _StockUpdateForm(StockUpdateViewModel model) { double totalLiabilityValue = StockLiabilityQueries.GetLiabilityValueOfStock(model.Id); if (model.StockValue < totalLiabilityValue && totalLiabilityValue > 0) { ModelState.AddModelError("CompareStockValueAndLiabilityValue", "Giá trị tổng số nợ không vượt quá giá trị cổ phiếu"); } StockUpdateViewModel stock = StockQueries.GetStockById(model.Id); if (!stock.Name.Equals(model.Name) && StockQueries.CheckExistStock(UserQueries.GetCurrentUsername(), model.Name)) { ModelState.AddModelError("DuplicateName", "Cổ phiếu này đã tồn tại"); } if (ModelState.IsValid) { int result = StockQueries.UpdateStock(model); if (result > 0) { return(Content("success")); } else { return(Content("failed")); } } else { return(PartialView(model)); } }
public ActionResult _LiabilityUpdateForm2nd(StockLiabilityUpdateViewModel model) { double totalLiabilityValue = StockLiabilityQueries.GetLiabilityValueOfStock(model.AssetId); double liabilityValue = StockLiabilityQueries.GetStockValue(model.Id); double stockValue = StockQueries.GetStockValue(model.AssetId); if (stockValue < totalLiabilityValue - liabilityValue + model.Value && totalLiabilityValue - liabilityValue + model.Value > 0) { ModelState.AddModelError("CompareStockValueAndLiabilityValue", "Giá trị tổng số nợ không vượt quá giá trị cổ phiếu"); } if (ModelState.IsValid) { int result = StockLiabilityQueries.UpdateStockLiability(model); if (result > 0) { return(Content("success")); } else { return(Content("failed")); } } else { return(PartialView(model)); } }
public ActionResult DeleteStock(int id) { int result = StockQueries.DeleteStock(id); if (result > 0) { return(Content("success")); } else { return(Content("failed")); } }
public ActionResult _AssetSummary() { AssetSummaryViewModel model = new AssetSummaryViewModel(); string username = UserQueries.GetCurrentUsername(); model.RealEstates = RealEstateQueries.GetRealEstateSummaryByUser(username); model.Businesses = BusinessQueries.GetBusinessSummaryByUser(username); model.BankDeposits = BankDepositQueries.GetBankDepositSummaryByUser(username); model.Stocks = StockQueries.GetStockSummaryByUser(username); model.Insurances = InsuranceQueries.GetInsuranceSummaryByUser(username); model.OtherAssets = OtherAssetQueries.GetOtherAssetSummaryByUser(username); return(PartialView(model)); }
public static async Task <string[]> GetDateListAsync() { IStockQueries dataLayer = new StockQueries(); return(await dataLayer.GetDaysAsync()); }
public static Task <Stock[]> GetStocksByBestStockTypeAsync(string name, string datetime) { IStockQueries dataLayer = new StockQueries(); return(dataLayer.GetStocksByBestStockTypeAsync(name, datetime)); }
public static Task <BestStockType[]> GetBestStockTypeAsync() { IStockQueries dataLayer = new StockQueries(); return(dataLayer.GetBestStockTypeAsync()); }
public static async Task <Stock[]> GetStocksByTypeAsync(string type, string datetime) { IStockQueries dataLayer = new StockQueries(); return(await dataLayer.GetStocksByTypeAsync(type, datetime)); }
public static async Task <Stock[]> GetStocksDateAsync(string datetime, int type) { IStockQueries dataLayer = new StockQueries(); return(await dataLayer.GetStocksByDateAsync(datetime, type)); }
public static Task <BrokerInfo[]> GetBrokersAsync(string stock, string date, int days) { IStockQueries dataLayer = new StockQueries(); return(dataLayer.GetBrokersAsync(stock, date, days)); }
public ActionResult _StockTable() { StockListViewModel model = StockQueries.GetStockByUser(UserQueries.GetCurrentUsername()); return(PartialView(model)); }
public static async Task SetBestStockAsync(string stockId, string type) { IStockQueries dataLayer = new StockQueries(); await dataLayer.SetBestStockAsync(stockId, type); }
public ActionResult _StockUpdateForm(int id) { StockUpdateViewModel model = StockQueries.GetStockById(id); return(PartialView(model)); }
public static async Task <string[]> GetChosenStockTypesAsync() { IStockQueries dataLayer = new StockQueries(); return(await dataLayer.GetChosenStockTypesAsync()); }
public static Task <StockeModel> GetPricesByStockIdAsync(string stockId, DateTime datetime, bool chkDate) { IStockQueries dataLayer = new StockQueries(); return(dataLayer.GetPricesByStockIdAsync(stockId, datetime, chkDate)); }
public static async Task <Stock[]> GetBestStocksAsync(int index) { IStockQueries dataLayer = new StockQueries(); return(await dataLayer.GetBestStocksAsync(index)); }