Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }