示例#1
0
        public bool Update(int id, Product model)
        {
            try
            {
                var result = _facturacionDbContext.Product.FirstOrDefault(x => x.Id == id);

                result.Name         = string.IsNullOrEmpty(model.Name) ? result.Name : model.Name;
                result.Descripcion  = string.IsNullOrEmpty(model.Descripcion) ? result.Descripcion : model.Descripcion;
                result.Price        = model.Price == 0 ? result.Price : model.Price;
                result.Stock        = model.Stock == 0 ? result.Stock : model.Stock;
                result.WarehouseId  = model.WarehouseId == 0 ? result.WarehouseId : model.WarehouseId;
                result.Deleted      = model.Deleted;
                result.ModifiedDate = DateTime.Now;

                _facturacionDbContext.Entry(result).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _facturacionDbContext.SaveChanges();

                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw e;
            }
        }
示例#2
0
        public bool Update(int id, Person model)
        {
            try
            {
                var result = _facturacionDbContext.Person.FirstOrDefault(x => x.Id == id);

                result.Name         = string.IsNullOrEmpty(model.Name) ? result.Name : model.Name;
                result.LastName     = string.IsNullOrEmpty(model.LastName) ? result.LastName : model.LastName;
                result.Phone        = string.IsNullOrEmpty(model.Phone) ? result.Phone : model.Phone;
                result.Email        = string.IsNullOrEmpty(model.Email) ? result.Email : model.Email;
                result.Address      = string.IsNullOrEmpty(model.Address) ? result.Address : model.Address;
                result.Gender       = model.Gender == 0 ? result.Gender : model.Gender;
                result.Deleted      = model.Deleted;
                result.ModifiedDate = DateTime.Now;

                _facturacionDbContext.Entry(result).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _facturacionDbContext.SaveChanges();

                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw e;
            }
        }
示例#3
0
        public bool Update(int id, Order model)
        {
            try
            {
                var result = _facturacionDbContext.Order.FirstOrDefault(x => x.Id == id);

                result.Deleted      = model.Deleted;
                result.ModifiedDate = DateTime.Now;

                _facturacionDbContext.Entry(result).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _facturacionDbContext.SaveChanges();

                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw e;
            }
        }