Beispiel #1
0
        public bool Update()
        {
            using (DBAssetModel ctx = new DBAssetModel())
            {
                var asset = ctx.DBAssets.Find(this);

                if (this.Name != null)
                {
                    asset.Name = this.Name;
                }

                if (this.IpAddress != null)
                {
                    asset.IpAddress = this.IpAddress;
                }

                asset.LastCheckin = DateTime.Now;
                asset.Storage     = false;
                asset.Deleted     = false;

                if (ctx.SaveChanges() == 1)
                {
                    return(true);
                }

                else
                {
                    return(false);
                }
            }
        }
Beispiel #2
0
        public async Task <bool> AddComment(string _comment, string user)
        {
            using (DBAssetModel ctx = new DBAssetModel())
            {
                //var asset = ctx.DBAssets.Find(this);

                var comment = new DBComment();

                comment.DBAssetID = this.SerialNumber;
                comment.Comment   = _comment;
                comment.AddedBy   = user;
                comment.DateAdded = DateTime.Now;

                ctx.DBComments.Add(comment);

                if (await ctx.SaveChangesAsync() == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #3
0
        public bool AddComment()
        {
            using (DBAssetModel ctx = new DBAssetModel())
            {
                ctx.DBComments.Add(this);

                if (ctx.SaveChanges() == 1)
                {
                    return(true);
                }

                else
                {
                    return(false);
                }
            }
        }
Beispiel #4
0
        public bool Store(bool _store = true)
        {
            using (DBAssetModel ctx = new DBAssetModel())
            {
                var asset = ctx.DBAssets.Find(this);
                asset.Storage = _store;

                if (ctx.SaveChanges() == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #5
0
        public bool Manage(bool _manage = true)
        {
            using (DBAssetModel ctx = new DBAssetModel())
            {
                var asset = ctx.DBAssets.Find(this);
                asset.Managed = _manage;

                if (ctx.SaveChanges() == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #6
0
        public bool Create()
        {
            this.LastCheckin  = DateTime.Now;
            this.CreationDate = DateTime.Now;
            this.Managed      = true;
            this.Storage      = false;
            this.Deleted      = false;

            using (DBAssetModel ctx = new DBAssetModel())
            {
                ctx.DBAssets.Add(this);

                if (ctx.SaveChanges() == 1)
                {
                    return(true);
                }

                else
                {
                    return(false);
                }
            }
        }