private JsonResult CreateData(StockTypeViewModel model) { if (_service.ExistedCode(model.Entity.TypeCode)) { return(Json(new { result = Constants.DuplicateCode })); } if (_service.ExistedName(model.Entity.TypeName)) { return(Json(new { result = Constants.Duplicate })); } try { model.Entity.iEnable = true; model.Entity.iCreated = model.LoginId; model.Entity.dCreated = DateTime.Now; _service.Insert(model.Entity); return(Json(new { result = Constants.Success })); } catch (Exception e) { Log.Error("Create New Store!", e); return(Json(new { result = Constants.UnSuccess })); } }
public ActionResult Create(int? id) { var userName = System.Web.HttpContext.Current.User.Identity.Name; var user = _systemService.GetUserAndRole(0, userName); if (user == null) { return RedirectToAction("Index", "Login"); } if (user.StockTypeR == 0) { return RedirectToAction("Index", "Home"); } var item = new WAMS_STOCK_TYPE(); if (id.HasValue) { item = _service.GetByKey(id.Value); } var model = new StockTypeViewModel { Id = item.Id, TypeCode = item.TypeCode, TypeName = item.TypeName, Timestamp = item.Timestamp, iCreated = item.iCreated, dCreated = item.dCreated, UserLogin = user }; // FUNCTION return View(model); }
public StockStatisticsViewModel GetStockStatistics(StockTypeViewModel stockType) { try { var stats = new StockStatisticsViewModel(); if (stockType == StockTypeViewModel.All) { stats.Count = _stockRepository.GetTotalCount(); stats.MarketValue = _stockRepository.GetTotalMarketValue(); stats.Weight = 1; return(stats); } var domainStockType = (StockType)stockType; var totalMarketValue = _stockRepository.GetTotalMarketValue(); stats.Count = _stockRepository.GetTotalCount(domainStockType); stats.MarketValue = _stockRepository.GetTotalMarketValue(domainStockType); stats.Weight = stats.MarketValue / totalMarketValue; return(stats); } catch (Exception ex) { _log.Error("Error while getting stock statistics.", ex); throw; } }
public JsonResult Create(StockTypeViewModel model) { if (model.V3 != true) { return(Json(new { result = Constants.UnSuccess })); } return(model.Entity.Id == 0 ? CreateData(model) : EditData(model)); }
public JsonResult Create(StockTypeViewModel model) { if (model.V3 != true) { return Json(new { result = Constants.UnSuccess }); } return model.Entity.Id == 0 ? CreateData(model) : EditData(model); }
private async void MainWindowLoadedEvent(object sender, RoutedEventArgs e) { StocksDataGrid.ItemsSource = new ObservableCollection <StockViewModel>(await _stockService.GetStocksAsync()); SummaryFilterCmb.DataContext = new List <string> { "All", "Equity", "Bond" }; _stockTypeFilter = StockTypeViewModel.All; SummaryFilterCmb.SelectedIndex = (int)_stockTypeFilter; }
public ActionResult LoadData(int page, int size, string code, string name, string enable) { var userName = System.Web.HttpContext.Current.User.Identity.Name; var totalRecord = _service.ListConditionCount(page, size, code, name, enable); var totalTemp = Convert.ToDecimal(totalRecord) / Convert.ToDecimal(size); var totalPages = Convert.ToInt32(Math.Ceiling(totalTemp)); var model = new StockTypeViewModel { UserLogin = _systemService.GetUserAndRole(0, userName), ListEntity = _service.ListCondition(page, size, code, name, enable), TotalRecords = Convert.ToInt32(totalRecord), TotalPages = totalPages, CurrentPage = page, PageSize = size }; return(PartialView("_StockTypePartial", model)); }
public ActionResult Index() { var userName = System.Web.HttpContext.Current.User.Identity.Name; var user = _systemService.GetUserAndRole(0, userName); if (user == null) { return(RedirectToAction("Index", "Login")); } if (user.StockTypeR == 0) { return(RedirectToAction("Index", "Home")); } var model = new StockTypeViewModel { UserLogin = user }; return(View(model)); }
private JsonResult EditData(StockTypeViewModel model) { if (model.CheckCode != model.Entity.TypeCode) { if (_service.ExistedCode(model.Entity.TypeCode)) { return(Json(new { result = Constants.DuplicateCode })); } } if (model.CheckName != model.Entity.TypeName) { if (_service.ExistedName(model.Entity.TypeName)) { return(Json(new { result = Constants.Duplicate })); } } var entity = _service.GetByKey(model.Entity.Id); if (!Convert.ToBase64String(model.Entity.Timestamp).Equals(Convert.ToBase64String(entity.Timestamp))) { return(Json(new { result = Constants.DataJustChanged })); } try { entity.TypeCode = model.Entity.TypeCode; entity.TypeName = model.Entity.TypeName; entity.iModified = model.LoginId; entity.dModified = DateTime.Now; _service.Update(entity); return(Json(new { result = Constants.Success })); } catch (Exception e) { Log.Error("Update Store!", e); return(Json(new { result = Constants.UnSuccess })); } }
public ActionResult Create(int?id) { var userName = System.Web.HttpContext.Current.User.Identity.Name; var user = _systemService.GetUserAndRole(0, userName); if (user == null) { return(RedirectToAction("Index", "Login")); } if (user.StockTypeR == 0) { return(RedirectToAction("Index", "Home")); } var item = new WAMS_STOCK_TYPE(); if (id.HasValue) { item = _service.GetByKey(id.Value); } var model = new StockTypeViewModel { Id = item.Id, TypeCode = item.TypeCode, TypeName = item.TypeName, Timestamp = item.Timestamp, iCreated = item.iCreated, dCreated = item.dCreated, UserLogin = user }; // FUNCTION return(View(model)); }
private void SummaryFilterCmbSelectionChanged(object sender, SelectionChangedEventArgs e) { _stockTypeFilter = (StockTypeViewModel)(sender as ComboBox).SelectedIndex; RefreshStatistics(); }
public void GetStockStatistics_rethrows_exception(StockTypeViewModel stockTypeViewModel) { _stockRepositoryFake.Setup(x => x.GetTotalMarketValue(It.IsAny <StockType>())).Throws(new Exception()); Assert.Throws <Exception>(() => _stockStatisticsService.GetStockStatistics(stockTypeViewModel)); }
private JsonResult EditData(StockTypeViewModel model) { if (model.CheckCode != model.Entity.TypeCode) { if (_service.ExistedCode(model.Entity.TypeCode)) { return Json(new { result = Constants.DuplicateCode }); } } if (model.CheckName != model.Entity.TypeName) { if (_service.ExistedName(model.Entity.TypeName)) { return Json(new { result = Constants.Duplicate }); } } var entity = _service.GetByKey(model.Entity.Id); if (!Convert.ToBase64String(model.Entity.Timestamp).Equals(Convert.ToBase64String(entity.Timestamp))) { return Json(new { result = Constants.DataJustChanged }); } try { entity.TypeCode = model.Entity.TypeCode; entity.TypeName = model.Entity.TypeName; entity.iModified = model.LoginId; entity.dModified = DateTime.Now; _service.Update(entity); return Json(new { result = Constants.Success }); } catch (Exception e) { Log.Error("Update Store!", e); return Json(new { result = Constants.UnSuccess }); } }
private JsonResult CreateData(StockTypeViewModel model) { if (_service.ExistedCode(model.Entity.TypeCode)) { return Json(new { result = Constants.DuplicateCode }); } if (_service.ExistedName(model.Entity.TypeName)) { return Json(new { result = Constants.Duplicate }); } try { model.Entity.iEnable = true; model.Entity.iCreated = model.LoginId; model.Entity.dCreated = DateTime.Now; _service.Insert(model.Entity); return Json(new { result = Constants.Success }); } catch (Exception e) { Log.Error("Create New Store!", e); return Json(new { result = Constants.UnSuccess }); } }
public ActionResult LoadData(int page, int size, string code, string name, string enable) { var userName = System.Web.HttpContext.Current.User.Identity.Name; var totalRecord = _service.ListConditionCount(page, size, code, name, enable); var totalTemp = Convert.ToDecimal(totalRecord) / Convert.ToDecimal(size); var totalPages = Convert.ToInt32(Math.Ceiling(totalTemp)); var model = new StockTypeViewModel { UserLogin = _systemService.GetUserAndRole(0, userName), ListEntity = _service.ListCondition(page, size, code, name, enable), TotalRecords = Convert.ToInt32(totalRecord), TotalPages = totalPages, CurrentPage = page, PageSize = size }; return PartialView("_StockTypePartial", model); }
public ActionResult Index() { var userName = System.Web.HttpContext.Current.User.Identity.Name; var user = _systemService.GetUserAndRole(0, userName); if (user == null) return RedirectToAction("Index", "Login"); if (user.StockTypeR == 0) return RedirectToAction("Index", "Home"); var model = new StockTypeViewModel { UserLogin = user }; return View(model); }