Exemplo n.º 1
0
        public void Update(T entity)
        {
            using var _context = new OtomasyonContext();

            _context.Update(entity);
            _context.SaveChanges();
        }
Exemplo n.º 2
0
        public void Add(T entity)
        {
            using var _context = new OtomasyonContext();

            _context.Set <T>().Add(entity);
            _context.SaveChanges();
        }
Exemplo n.º 3
0
        public List <Messages> GetMessages()
        {
            using var context = new OtomasyonContext();
            var mesaj = context.Messages.Where(x => x.Sender == "Admin").ToList();

            return(mesaj);
        }
Exemplo n.º 4
0
        public void Delete(T entity)
        {
            using var _context = new OtomasyonContext();

            _context.Set <T>().Remove(entity);
            _context.SaveChanges();
        }
Exemplo n.º 5
0
 public List <T> denemeexp(Expression <Func <T, bool> > filter = null)
 {
     using var _context = new OtomasyonContext();
     return(filter == null
         ? _context.Set <T>().ToList()
         : _context.Set <T>().Where(filter).ToList());
 }
        public List <FaturaKalem> GetFaturaKalemsWithBill(int billId)
        {
            using var context = new OtomasyonContext();
            var dgr = context.FaturaKalems.Where(x => x.BillsId == billId).Include(x => x.Bills).ToList();

            return(dgr);
        }
        public List <AppUser> GetPerconels()
        {
            using var context = new OtomasyonContext();
            var value = context.Users.Join(context.UserRoles, x => x.Id, y => y.UserId, (resultUser, resultRole) => new
            {
                user = resultUser,
                role = resultRole
            }).Join(context.Roles, x => x.role.RoleId, y => y.Id, (table, roles) => new
            {
                user     = table.user,
                userRole = table.role,
                Roles    = roles
            }).Join(context.Departmen, x => x.user.DepartmanId, y => y.Id, (table2, departman) => new
            {
                allTable = table2,
                dep      = departman
            }).Where(x => x.allTable.Roles.Name == "Perconel").Select(x => new AppUser()
            {
                Id          = x.allTable.user.Id,
                Departman   = x.dep,
                DepartmanId = x.allTable.user.DepartmanId,
                City        = x.allTable.user.City,
                Name        = x.allTable.user.Name,
                Email       = x.allTable.user.Email,
                UserName    = x.allTable.user.UserName,
                Surname     = x.allTable.user.Surname
            }).ToList();

            return(value);
        }
Exemplo n.º 8
0
        public void DeleteSoft(int id)
        {
            using var context = new OtomasyonContext();
            var product = context.Products.Find(id);

            product.LimitState = false;
            context.SaveChanges();
        }
Exemplo n.º 9
0
        public void DeleteSoft(int id)
        {
            using var context = new OtomasyonContext();
            var category = context.Categories.Find(id);

            category.LimitState = false;
            context.SaveChanges();
        }
Exemplo n.º 10
0
        public void DecreaseStoc(int id, int number)
        {
            using var context = new OtomasyonContext();

            var product = context.Products.Find(id);

            product.Stok = (short)(product.Stok - number);
            context.SaveChanges();
        }
        public List <decimal> GetInvoiceItemsWithBills(int billId)
        {
            using var context = new OtomasyonContext();
            var dgr = context.FaturaKalems.Where(x => x.BillsId == billId).Include(x => x.Bills).Select(y => y.Tutar).ToList();

            decimal toplam = 0;

            foreach (var item in dgr)
            {
                toplam = item + toplam;
            }
            var bill = context.Bills.Find(billId);

            bill.Total = toplam;
            context.SaveChanges();
            return(dgr);
        }
Exemplo n.º 12
0
        public Product GetProductWithCategoryId(int id)
        {
            using var context = new OtomasyonContext();
            //var product = context.Products.Join(context.Categories, x => x.CategoryId, y => y.Id, (resultproduct, resultcategory) => new Product
            //{

            //    Id = resultproduct.Id,
            //    SellingMoves = resultproduct.SellingMoves,
            //    SellingPrice = resultproduct.SellingPrice,
            //    Stok = resultproduct.Stok,
            //    Category = resultcategory,
            //    CategoryId = resultproduct.CategoryId

            //}).Where(x => x.Id == id).FirstOrDefault();
            var product = context.Products.Where(i => i.LimitState == true).Include(x => x.Category).FirstOrDefault(x => x.Id == id);

            return(product);
        }
Exemplo n.º 13
0
        public SellingMoves GetSellingMovewithProduct(int id)
        {
            using var context = new OtomasyonContext();
            var deger = context.sellingMoves.Include(x => x.Products).Join(context.Users, x => x.AppUserId, user => user.Id, (moves, Current) => new
            {
                moves   = moves,
                Current = Current
            }).Select(x => new SellingMoves
            {
                Id         = x.moves.Id,
                Adet       = x.moves.Adet,
                AppUserId  = x.moves.Id,
                Cariler    = x.Current,
                Date       = x.moves.Date,
                Price      = x.moves.Price,
                Products   = x.moves.Products,
                ProductId  = x.moves.ProductId,
                TotalPrice = x.moves.TotalPrice
            }).Where(x => x.Id == id).FirstOrDefault();

            return(deger);
        }
Exemplo n.º 14
0
        public List <SellingMoves> GetSellingMovesWithPerconelFilter()
        {
            using var context = new OtomasyonContext();
            var deger = context.sellingMoves.Include(x => x.Products).Join(context.Users, x => x.AppUserId, user => user.Id, (moves, Current) => new
            {
                moves   = moves,
                Current = Current
            }).Select(x => new SellingMoves
            {
                Id         = x.moves.Id,
                Adet       = x.moves.Adet,
                AppUserId  = x.moves.Id,
                Cariler    = x.Current,
                Date       = x.moves.Date,
                Price      = x.moves.Price,
                Products   = x.moves.Products,
                ProductId  = x.moves.ProductId,
                TotalPrice = x.moves.TotalPrice
            }).ToList();

            return(deger);
        }
Exemplo n.º 15
0
        public T GetById(int id)
        {
            using var _context = new OtomasyonContext();

            return(_context.Set <T>().Find(id));
        }
Exemplo n.º 16
0
 public List <Product> GetProductsWithCategories()
 {
     using var context = new OtomasyonContext();
     return(context.Products.Where(i => i.LimitState == true).Include(x => x.Category).ToList());
 }
Exemplo n.º 17
0
 public List <T> GetAll()
 {
     using var _context = new OtomasyonContext();
     return(_context.Set <T>().ToList());
 }