public async Task <ActionResult> MarketEdit(long id = 0) { var model = new StockMarketModel(); if (id == 0) { return(PartialView(model)); } var market = await StockMarketRepository.GetEnableByIdAsync(id); if (market == null) { var json = new JsonModel { message = "记录不存在了", statusCode = 300 }; return(Json(json, JsonRequestBehavior.AllowGet)); } Mapper.Map(market, model); return(PartialView(model)); }
public async Task <ActionResult> MarketEdit(StockMarketModel model) { var result = new JsonModel(); if (!ModelState.IsValid) { result.GetError(ModelState); return(Json(result)); } StockMarket market = null; var operationType = OperationType.Update; if (model.Id > 0) { operationType = OperationType.Update; market = await StockMarketRepository.GetEnableByIdAsync(model.Id); if (market == null) { result.statusCode = 300; result.message = "该条数据不存在,请刷新重试!"; return(Json(result)); } } else { market = new StockMarket(); } Mapper.Map(model, market); market.CommonStatus = CommonStatus.Enabled; await StockMarketRepository.SaveAsync(market); await LogRepository.Insert(TableSource.StockMarket, operationType, "", market.Id); result.Data = market; result.message = "保存成功!"; return(Json(result)); }
public async Task <ActionResult> MarketDelete(string ids) { var result = new JsonModel { statusCode = 300, message = "删除失败,记录不存在!", closeCurrent = false }; if (string.IsNullOrEmpty(ids)) { return(Json(result)); } var list = await StockMarketRepository.BatchDeleteAsync(ids); if (list == null) { return(Json(result)); } var msg = string.Join(",", list.Select(m => m.Name).ToArray()).ToEllipsis(100); await LogRepository.Insert(TableSource.StockMarket, OperationType.Delete, string.Format("批量删除{0}等股票市场", msg), ids); result.statusCode = 200; result.message = "删除成功!"; return(Json(result)); }
public async Task <ActionResult> MarketList() { var list = await StockMarketRepository.GetListAsync(); return(View(list)); }