//编辑
 public CheckContents Edit(CheckContents CheckContents)
 {
     DBEntity.CheckContents.Attach(CheckContents);
           DBEntity.Entry<CheckContents>(CheckContents).State = EntityState.Modified;
           DBEntity.SaveChanges();
           return CheckContents;
 }
Beispiel #2
0
        private ValidationContext(
            Guid contentId,
            Guid schemaId,
            CheckContents checkContent,
            CheckContentsByIds checkContentByIds,
            CheckAssets checkAsset,
            ImmutableQueue <string> propertyPath,
            bool isOptional,
            ValidationMode mode = ValidationMode.Default)
        {
            Guard.NotNull(checkAsset);
            Guard.NotNull(checkContent);
            Guard.NotNull(checkContentByIds);

            this.propertyPath = propertyPath;

            this.checkContent      = checkContent;
            this.checkContentByIds = checkContentByIds;
            this.checkAsset        = checkAsset;
            this.contentId         = contentId;

            this.schemaId = schemaId;

            Mode = mode;

            IsOptional = isOptional;
        }
 public ValidationContext(
     Guid contentId,
     Guid schemaId,
     CheckContents checkContent,
     CheckAssets checkAsset)
     : this(contentId, schemaId, checkContent, checkAsset, ImmutableQueue <string> .Empty, false)
 {
 }
Beispiel #4
0
 public ValidationContext(
     Guid contentId,
     Guid schemaId,
     CheckContents checkContent,
     CheckContentsByIds checkContentsByIds,
     CheckAssets checkAsset,
     ValidationMode mode = ValidationMode.Default)
     : this(contentId, schemaId, checkContent, checkContentsByIds, checkAsset, ImmutableQueue <string> .Empty, false, mode)
 {
 }
        private ValidationContext(
            Guid contentId,
            Guid schemaId,
            CheckContents checkContent,
            CheckAssets checkAsset,
            ImmutableQueue <string> propertyPath,
            bool isOptional)
        {
            Guard.NotNull(checkAsset, nameof(checkAsset));
            Guard.NotNull(checkContent, nameof(checkAsset));

            this.propertyPath = propertyPath;

            this.checkContent = checkContent;
            this.checkAsset   = checkAsset;
            this.contentId    = contentId;

            this.schemaId = schemaId;

            IsOptional = isOptional;
        }
 //新增
 public CheckContents Add(CheckContents CheckContents)
 {
     DBEntity.CheckContents.Add(CheckContents);
                  DBEntity.SaveChanges();
              return  CheckContents ;
 }
        // PUT api/CheckContents/5
        public HttpResponseMessage Put(CheckContents NewCheckContents)
        {
            try
            {

                if (NewCheckContents == null)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }
                else
                {
                    //待编辑的字段赋值

                    ICheckContents.Edit(NewCheckContents);
                    return Request.CreateResponse(HttpStatusCode.OK);
                }
            }
            catch (Exception)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
        // GET api/CheckContents/5
        //public CheckContents Get(int id)
        //{
        //    return ICheckContents.GetOne(a => a.Id == id);
        //}
        // post api/CheckContents
        public HttpResponseMessage Post(CheckContents NewCheckContents)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Users NowUser = ToGetNowUser();
                    NewCheckContents.UserId = NowUser.Id;
                    var c = db.CheckContents.Add(NewCheckContents);
                    db.SaveChanges();
                    string allRule = "";
                    NewCheckContents.CheckPoints.ToList().ForEach(x => allRule = allRule + x.RefRules + ",");
                    var tempAllRuleAll = allRule.Split(',');
                    var tempAllRule = tempAllRuleAll.Distinct().ToList();
                    int tempLen = tempAllRule.Count() - 1;
                    for (int i = 0; i < tempLen; i++)
                    {
                        int Id = Convert.ToInt32(tempAllRule[i]);
                        var rul = db.CheckRefRules.FirstOrDefault(x => x.Id == Id);
                        if (rul != null)
                        {
                            rul.IsUsed = 1;
                            db.Entry<CheckRefRules>(rul).State = EntityState.Modified;
                        }
                    }
                    db.SaveChanges();

                    return Request.CreateResponse(HttpStatusCode.OK);
                }
                else
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }
            }
            catch (Exception)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }