Beispiel #1
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public Msg Add(Module item)
 {
     var msg = new Msg();
     try
     {
         dbContext.Module.Add(item);
         dbContext.SaveChanges();
     }
     //DbEntityValidationException ex
     catch (Exception ex)
     {
         msg.IsError = true;
         msg.Desc = ex.Message;
     }
     return msg;
 }
Beispiel #2
0
        public HttpResponseMessage PostModule(Module item)
        {
            var msg = new Msg();

            if (!tools.VerifyUserOfModule(item.GroupId))
            {
                msg.IsError = true;
                msg.Desc = "对不起,你没有此设计中心组件的编辑权限。";
                return Request.CreateResponse<Msg>(HttpStatusCode.OK, msg);
            }

            if (ModelState.IsValid)
            {
                item.UpdateTime = DateTime.Now;
                msg = moduleRepository.Add(item);
                var data = new
                {
                    Id = item.Id,
                    Name = item.Name,
                    GroupId = item.GroupId,
                    CategoryId = item.CategoryId,
                    RelyMods = item.RelyMods,
                    Img = item.Img,
                    Css = item.Css,
                    Html = item.Html,
                    Javascript = item.Javascript,
                    UpdateBy = item.UpdateBy,
                    UpdateTime = item.UpdateTime.ToString("yyyy/MM/dd hh:mm:ss")

                };
                msg.Data = data;
            }
            else
            {
                msg.IsError = true;
                msg.Desc = "字段验证失败,请检查字段的值是否符合规则。";
            }
            return Request.CreateResponse<Msg>(HttpStatusCode.Created, msg);
        }
Beispiel #3
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public Msg Update(Module item)
 {
     var msg = new Msg();
     try
     {
         dbContext.Entry(item).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
     catch (Exception ex)
     {
         msg.IsError = true;
         msg.Desc = ex.Message;
     }
     return msg;
 }