示例#1
0
        public int Delete(AnatomyTag s, bool purge = false)
        {
            if (s == null)
            {
                return(0);
            }

            if (!this.DataAccessAuthorized(s, "DELETE", false))
            {
                return(0);
            }

            if (purge)
            {
                using (var context = new GreenWerxDbContext(this._connectionKey))
                {
                    return(context.Delete <AnatomyTag>(s));
                }
            }

            //get the AnatomyTag from the table with all the data so when its updated it still contains the same data.
            s = this.GetAnatomyTagBy(s.UUID);
            if (s == null)
            {
                return(0);
            }
            s.Deleted = true;
            using (var context = new GreenWerxDbContext(this._connectionKey))
            {
                return(context.Update <AnatomyTag>(s));
            }
        }
示例#2
0
        public ServiceResult Insert(AnatomyTag s)
        {
            using (var context = new GreenWerxDbContext(this._connectionKey))
            {
                AnatomyTag dbU = context.GetAll <AnatomyTag>()?.FirstOrDefault(wu => wu.Name.EqualsIgnoreCase(s.Name) && wu.AccountUUID == s.AccountUUID);

                if (dbU != null)
                {
                    return(ServiceResponse.Error("AnatomyTag already exists."));
                }

                s.UUID     = Guid.NewGuid().ToString("N");
                s.UUIDType = "AnatomyTag";

                if (!this.DataAccessAuthorized(s, "post", false))
                {
                    return(ServiceResponse.Error("You are not authorized this action."));
                }

                if (context.Insert <AnatomyTag>(s))
                {
                    return(ServiceResponse.OK("", s));
                }
            }
            return(ServiceResponse.Error("An error occurred inserting AnatomyTag " + s.Name));
        }
示例#3
0
        public ServiceResult Update(AnatomyTag s)
        {
            if (s == null)
            {
                return(ServiceResponse.Error("Invalid AnatomyTag data."));
            }

            if (!this.DataAccessAuthorized(s, "PATCH", false))
            {
                return(ServiceResponse.Error("You are not authorized this action."));
            }

            using (var context = new GreenWerxDbContext(this._connectionKey))
            {
                if (context.Update <AnatomyTag>(s) > 0)
                {
                    return(ServiceResponse.OK());
                }
            }
            return(ServiceResponse.Error("System error, AnatomyTag was not updated."));
        }