public JsonResult Edit(RiceDate model)
        {
            try
            {
                if (model.RiceDateId > 0)
                {
                    var entity = _RiceDateService.GetById(model.RiceDateId);

                    ////修改
                    //entity.BaseImageId = model.BaseImageId;
                    //entity.BusinessInfoId = model.BusinessInfoId;
                    //entity.Name = model.Name;
                    //entity.Content = model.Content;
                    //entity.EditTime = DateTime.Now;

                    _RiceDateService.Update(model);
                }
                else
                {
                    //添加
                    model.Status     = (int)OrderingSystem.Domain.EnumHelp.EnabledEnum.效;
                    model.IsDelete   = (int)OrderingSystem.Domain.EnumHelp.IsDeleteEnum.效;
                    model.CreateTime = DateTime.Now;
                    model.EditTime   = DateTime.Now;

                    _RiceDateService.Insert(model);
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public ResponseModel <int> PublicRiceDate(RiceDateDTO RiceDateDTO)
        {
            var result = new ResponseModel <int>();

            result.error_code = Result.SUCCESS;
            var user = _userService.GetById(RiceDateDTO.UserId);

            if (user != null && user.UserId > 0)
            {
                if (user.IsDelete == (int)EnumHelp.IsDeleteEnum.已删除 || user.Status == (int)EnumHelp.EnabledEnum.无效)
                {
                    result.error_code = Result.ERROR;
                    result.message    = "用户Id无效";
                    return(result);
                }
                else
                {
                    string[] ids           = RiceDateDTO.BaseImageIds.Split(',').ToArray();
                    int[]    output        = Array.ConvertAll <string, int>(ids, delegate(string s) { return(int.Parse(s)); });
                    var      baseImageList = _baseImageService.GetByIds(output);
                    if (baseImageList.Count != output.Length)
                    {
                        result.error_code = Result.ERROR;
                        result.message    = "展示图id有误";
                        return(result);
                    }
                    var riceDate = new RiceDate()
                    {
                        Address      = RiceDateDTO.Address,
                        Age          = RiceDateDTO.Age,
                        BeginDate    = RiceDateDTO.BeginDate,
                        BusinessName = RiceDateDTO.BusinessName,
                        CreateTime   = System.DateTime.Now,
                        EditTime     = System.DateTime.Now,
                        PayWay       = RiceDateDTO.PayWay,
                        Remark       = RiceDateDTO.Remark,
                        Sex          = RiceDateDTO.Sex,
                        Taste        = RiceDateDTO.Taste,
                        UserCount    = RiceDateDTO.UseCount,
                        Zone         = RiceDateDTO.Zone,
                        UserId       = RiceDateDTO.UserId,
                        BaseImageIds = RiceDateDTO.BaseImageIds,
                        IsDelete     = (int)EnumHelp.IsDeleteEnum.效,
                        Status       = (int)EnumHelp.EnabledEnum.效
                    };
                    var InsertResult = _riceDateService.Insert(riceDate);
                    result.data = InsertResult.RiceDateId;
                }
            }
            else
            {
                result.data       = 0;
                result.error_code = Result.ERROR;
                result.message    = "用户不存在";
            }
            return(result);
        }