Exemple #1
0
        public async Task <OrderItemDTO> OrderItemUpdate(OrderItemDTO orderItemDTO)
        {
            var dataObject = orderItemDTO as Order_Item;

            _sqlServerContext.Update <Order_Item>(dataObject);
            await _sqlServerContext.SaveChangesAsync();

            return(orderItemDTO);
        }
Exemple #2
0
        public async Task <Supplier> UpdateSupplier(int supplierId, Supplier supplier)
        {
            using (var transaction = _sqlServerContext.Database.BeginTransaction())
            {
                try
                {
                    var entity = await _sqlServerContext.Suppliers.FirstOrDefaultAsync(item => item.SupplierId == supplierId);

                    if (entity != null)
                    {
                        entity.SupplierName = supplier.SupplierName;
                        entity.CompanyId    = supplier.CompanyId;
                        entity.CountryId    = supplier.CountryId;
                        entity.PostalCode   = supplier.PostalCode;
                        entity.VatNumber    = supplier.VatNumber;
                        entity.Email        = supplier.VatNumber;
                        entity.Phone        = supplier.Phone;
                        entity.Address      = supplier.Address;
                        entity.City         = supplier.City;
                        entity.State        = supplier.State;
                        entity.IsActive     = supplier.IsActive;
                        entity.CreatedDate  = supplier.CreatedDate;
                        entity.CreatedBy    = supplier.CreatedBy;
                        entity.UpdatedBy    = supplier.UpdatedBy;
                        entity.UpdatedDate  = supplier.UpdatedDate;

                        _sqlServerContext.Update(entity);
                        await _sqlServerContext.SaveChangesAsync();
                    }
                    else
                    {
                        entity.SupplierId   = 0;
                        entity.SupplierName = "";
                        entity.CompanyId    = 0;
                        entity.CountryId    = 0;
                        entity.PostalCode   = "";
                        entity.VatNumber    = "";
                        entity.Email        = "";
                        entity.Phone        = "";
                        entity.Address      = "";
                        entity.City         = "";
                        entity.State        = "";
                        entity.IsActive     = false;
                        entity.CreatedDate  = DateTime.Now;
                        entity.CreatedBy    = 0;
                        entity.UpdatedBy    = 0;
                        entity.UpdatedDate  = DateTime.Now;
                    }
                    transaction.Commit();
                    return(entity);
                }
                catch (Exception exception)
                {
                    transaction.Rollback();
                    throw exception;
                }
            }
        }
Exemple #3
0
        public async Task <CustomerDTO> CustomerUpdate(CustomerDTO customerDTO)
        {
            var dataObejct = customerDTO as CustomerDTO;

            _sqlServerContext.Update(customerDTO);
            await _sqlServerContext.SaveChangesAsync();

            return(customerDTO);
        }
        public async Task <EmployeeDTO> EmployeeUpdate(EmployeeDTO employeeDTO)
        {
            var dataObject = employeeDTO as Employee;

            _sqlServerContext.Update <Employee>(dataObject);
            await _sqlServerContext.SaveChangesAsync();

            return(employeeDTO);
        }
        public async Task <LocationDTO> LocationEntryUpdate(LocationDTO locationDTO)
        {
            var dataObject = locationDTO as Location;

            if (locationDTO.LocationId == 0)
            {
                await _sqlServerContext.AddAsync <Location>(dataObject);
            }
            else
            {
                _sqlServerContext.Update <Location>(dataObject);
            }



            await _sqlServerContext.SaveChangesAsync();

            return(locationDTO);
        }
        public async Task <ProductDTO> ProductEntryUpdate(ProductDTO productDTO)
        {
            var dataObject = productDTO as Product;

            if (productDTO.ProductId == 0)
            {
                await _sqlServerContext.AddAsync <Product>(dataObject);
            }
            else
            {
                _sqlServerContext.Update <Product>(dataObject);
            }
            await _sqlServerContext.SaveChangesAsync();

            return(productDTO);
        }
        public async Task <Product> UpdateProduct(int productId, Product product)
        {
            using (var transaction = _sqlServerContext.Database.BeginTransaction())
            {
                try
                {
                    var entity = await _sqlServerContext.Products.FirstOrDefaultAsync(item => item.ProductId == productId);

                    if (entity != null)
                    {
                        entity.CategoryId  = product.CategoryId;
                        entity.ProductName = product.ProductName;
                        entity.ProductCode = product.ProductCode;
                        entity.SerialNo    = product.SerialNo;
                        entity.TypeId      = product.TypeId;
                        entity.UnitId      = product.UnitId;
                        entity.BrandId     = product.BrandId;
                        entity.ImageURL    = product.ImageURL;
                        entity.Cost        = product.Cost;
                        entity.Price       = product.Price;
                        entity.Quantity    = product.Quantity;
                        entity.IsActive    = product.IsActive;
                        entity.CreatedDate = product.CreatedDate;
                        entity.CreatedBy   = product.CreatedBy;
                        entity.UpdatedBy   = product.UpdatedBy;
                        entity.UpdatedDate = product.UpdatedDate;

                        _sqlServerContext.Update(entity);
                        await _sqlServerContext.SaveChangesAsync();

                        transaction.Commit();
                    }
                    else
                    {
                        entity.ProductId   = 0;
                        entity.CategoryId  = 0;
                        entity.ProductName = "";
                        entity.ProductCode = "";
                        entity.SerialNo    = "";
                        entity.TypeId      = 0;
                        entity.UnitId      = 0;
                        entity.BrandId     = 0;
                        entity.ImageURL    = "";
                        entity.Cost        = 0;
                        entity.Price       = 0;
                        entity.Quantity    = 0;
                        entity.IsActive    = false;
                        entity.CreatedDate = DateTime.Now;
                        entity.CreatedBy   = 0;
                        entity.UpdatedBy   = 0;
                        entity.UpdatedDate = DateTime.Now;
                    }
                    return(entity);
                }
                catch (Exception exception)
                {
                    transaction.Rollback();
                    throw exception;
                }
            }
        }