/// <summary>
 /// 创建一个food_list
 /// </summary>
 /// <param name="db">实体数据</param>
 /// <param name="entity">将要创建的一个food_list</param>
 public void Create(SysEntities db, food_list entity)
 {
     if (entity != null)
     {
         db.food_list.AddObject(entity);
     }
 }
        public ActionResult Create(food_list entity)
        {
            if (entity != null && ModelState.IsValid)
            {
                //string currentPerson = GetCurrentPerson();
                //entity.CreateTime = DateTime.Now;
                //entity.CreatePerson = currentPerson;
                entity.userid   = GetCurrentPerson();
                entity.filltime = DateTime.Now;

                string returnValue = string.Empty;
                if (m_BLL.Create(ref validationErrors, entity))
                {
                    LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.InsertSucceed + ",food_list的信息的Id为" + entity.id, "food_list",
                                                   Result.Succeed);//写入日志
                    return(Json(Suggestion.InsertSucceed));
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return(true);
                        });
                    }
                    LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.InsertFail + ",food_list的信息," + returnValue, "food_list",
                                                   Result.Fail);       //写入日志
                    return(Json(Suggestion.InsertFail + returnValue)); //提示插入失败
                }
            }

            return(Json(Suggestion.InsertFail + ",请核对输入的数据的格式")); //提示输入的数据的格式不对
        }
        public ActionResult Edit(int id, food_list entity)
        {
            if (entity != null && ModelState.IsValid)
            {   //数据校验
                //string currentPerson = GetCurrentPerson();
                //entity.UpdateTime = DateTime.Now;
                //entity.UpdatePerson = currentPerson;

                string returnValue = string.Empty;
                if (m_BLL.Edit(ref validationErrors, entity))
                {
                    LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateSucceed + ",food_list信息的Id为" + id, "food_list",
                                                   Result.Succeed); //写入日志
                    return(Json(Suggestion.UpdateSucceed));         //提示更新成功
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return(true);
                        });
                    }
                    LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateFail + ",food_list信息的Id为" + id + "," + returnValue, "food_list",
                                                   Result.Fail);       //写入日志
                    return(Json(Suggestion.UpdateFail + returnValue)); //提示更新失败
                }
            }
            return(Json(Suggestion.UpdateFail + "请核对输入的数据的格式")); //提示输入的数据的格式不对
        }
Exemple #4
0
 /// <summary>
 /// 创建一个food_list
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个food_list</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, food_list entity)
 {
     try
     {
         return(repository.Create(entity) == 1);
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
Exemple #5
0
 /// <summary>
 /// 编辑一个food_list
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="entity">一个food_list</param>
 /// <returns></returns>
 public bool Edit(ref ValidationErrors validationErrors, food_list entity)
 {
     try
     {
         repository.Edit(db, entity);
         return(repository.Save(db) == 1);
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
        public ActionResult Details(int id)
        {
            food_list item = m_BLL.GetById(id);

            return(View(item));
        }