public bool Insert(OvertimeParam overtimeParam)
        {
            try
            {
                var result = 0;
                overtime.createDate = DateTimeOffset.Now.LocalDateTime;
                overtime.check_in = overtimeParam.check_in;
                overtime.employee_id = overtimeParam.employee_id;
                _context.Overtimes.Add(overtime);
                result = _context.SaveChanges();

                if (result > 0)
                {
                    status = true;
                    MessageBox.Show("Login Successfully");
                }
            }
            catch(Exception e)
            {
                MessageBox.Show(e.StackTrace);
            }
            
            return status;

        }
        // adding new product to database
        public void AddNewProduct(NewProductViewModel newProduct)
        {
            ProductEntity newProductEntity = _mapper.Map <ProductEntity>(newProduct);

            _myContex.Products.Add(newProductEntity);
            _myContex.SaveChanges();
        }
        public bool delete(int?id)
        {
            var      result    = 0;
            Position positions = Get(id);

            positions.isDelete   = true;
            positions.deleteDate = DateTimeOffset.Now.LocalDateTime;
            result = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
            }
            return(status);
            //throw new NotImplementedException();
        }
Exemple #4
0
        public bool insert(ApprovalParam approvalParam)
        {
            var result = 0;

            approval.employee_id     = approvalParam.employee_id;
            approval.overtime_id     = approvalParam.overtime_id;
            approval.reason          = approvalParam.reason;
            approval.approval_status = approvalParam.approval_status;
            approval.isDelete        = false;
            _context.Approvals1.Add(approval);
            result = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
        public void AddUserFavourite(User currentUser, Station selectedStation)
        {
            var newFavourite = new FavouriteStation(_context.Stations.FirstOrDefault(station => station.Name == selectedStation.Name), "");

            if (ActiveUser(currentUser).FavouriteStations == null)
            {
                ActiveUser(currentUser).FavouriteStations
                    = new List <FavouriteStation>()
                    {
                    newFavourite
                    };
            }
            else
            {
                ActiveUser(currentUser).FavouriteStations.Add(newFavourite);
            }
            _context.SaveChanges();
        }
        public bool update(int?id, ApprovalParam approvalParam)
        {
            var       result   = 0;
            Approvals approval = Get(id);

            approval.approval_status = approvalParam.approval_status;
            result = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
        // creating new cart and saving that to database with state "cart"
        public int CreateNewCartOrder(CustomerEntity loggedUser, ItemCartViewModel itemCart)
        {
            OrderEntity order = new OrderEntity()
            {
                CustomerId  = loggedUser.CustomerId,
                StateOrder  = "cart",
                DateOrder   = DateTime.Now,
                StatusOrder = "W realizacji",
            };

            _myContex.Orders.Add(order);
            _myContex.SaveChanges();

            int orderId = _myContex.Orders.OrderByDescending(s => s.OrderId)
                          .Where(o => o.CustomerId == loggedUser.CustomerId)
                          .Where(o => o.StateOrder == "cart")
                          .FirstOrDefault().OrderId;

            // create object with order details and save in database
            OrderDetailEntity orderDetail = new OrderDetailEntity()
            {
                ProductId               = itemCart.ProductId,
                ProductSymbol           = itemCart.ProductSymbol,
                ProductName             = itemCart.ProductName,
                OrderId                 = orderId,
                Quantity                = itemCart.Quantity,
                CurrentStockInWholesale = GetCurrentStockInWholesale(itemCart.ProductId),
                Price = itemCart.Price,
                Value = itemCart.Quantity * itemCart.Price,
            };

            _myContex.OrderDetails.Add(orderDetail);
            _myContex.SaveChanges();

            // decrease current item stock in database
            DecreaseStockInWholesale(itemCart);

            return(orderId);
        }
 // update products stock in database
 public void UpdateStockInDatabase(List <ProductAPI> productsListFromSubiektAPI)
 {
     foreach (ProductAPI product in productsListFromSubiektAPI)
     {
         ProductEntity productFromDatabase = _myContex.Products.Where(x => x.IdSubiekt == product.IdSubiekt).FirstOrDefault();
         if (productFromDatabase is null)
         {
             continue;
         }
         productFromDatabase.Stock = product.Stock;
         _myContex.SaveChanges();
     }
 }
Exemple #9
0
        public bool Delete(int?id)
        {
            var       result   = 0;
            Employees employee = Get(id);

            employee.isDelete   = true;
            employee.deleteDate = DateTimeOffset.Now.LocalDateTime;
            result = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
            }
            return(status);
        }