public async Task <Equipment> Update(Equipment item)
        {
            using (_db = new AnbarDbContext())
            {
                try
                {
                    var find = await _db.Equipments.Where(a => a.Id == item.Id).FirstOrDefaultAsync();

                    if (find != null)
                    {
                        find.AmvalNumber = item.AmvalNumber;
                        find.Model       = item.Model;
                        find.Serial      = item.Serial;
                        find.Name        = item.Name;
                        await _db.SaveChangesAsync();

                        return(find);
                    }
                }
                catch (Exception ex)
                {
                }
                return(null);
            }
        }
        public async Task <bool> Add(Device item)
        {
            using (_db = new AnbarDbContext())
            {
                try
                {
                    _db.Devices.Add(item);
                    await _db.SaveChangesAsync();

                    return(true);
                }
                catch (Exception ex)
                {
                }
                return(false);
            }
        }
        public async Task <bool> Delete(int Id)
        {
            using (_db = new AnbarDbContext())
            {
                try
                {
                    var find = await _db.Devices.Where(a => a.Id == Id).FirstOrDefaultAsync();

                    if (find != null)
                    {
                        _db.Devices.Remove(find);
                        await _db.SaveChangesAsync();

                        return(true);
                    }
                }
                catch (Exception ex)
                {
                }
                return(false);
            }
        }
Esempio n. 4
0
        public async Task <DeviceType> Update(DeviceType item)
        {
            using (_db = new AnbarDbContext())
            {
                try
                {
                    var find = await _db.DeviceTypes.Where(a => a.Id == item.Id).FirstOrDefaultAsync();

                    if (find != null)
                    {
                        find.Name = item.Name;
                        await _db.SaveChangesAsync();

                        return(find);
                    }
                }
                catch (Exception ex)
                {
                }
                return(null);
            }
        }
        public async Task <User> Update(User item)
        {
            using (_db = new AnbarDbContext())
            {
                try
                {
                    var find = await _db.Users.Where(a => a.Id == item.Id).FirstOrDefaultAsync();

                    if (find != null)
                    {
                        find.Name     = item.Name;
                        find.Password = item.Password;
                        find.Username = item.Username;
                        await _db.SaveChangesAsync();

                        return(find);
                    }
                }
                catch (Exception ex)
                {
                }
                return(null);
            }
        }