Ejemplo n.º 1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var db = MyDbContext.Create();
            var _destinationPath = AppDomain.CurrentDomain.BaseDirectory + "Images\\";

            _destinationPath = _destinationPath.Replace("\\", "/");
            _destinationPath = _destinationPath.Replace("/bin/Debug", "");
            var imagePath = db.Products.Select(x => x.ImagePath).FirstOrDefault();

            if (!_destinationPath.Contains(imagePath))
            {
                foreach (var overwritePath in db.Products)
                {
                    overwritePath.ImagePath = _destinationPath + Path.GetFileName(overwritePath.ImagePath);
                }

                db.SaveChanges();
            }


            base.OnStartup(e);
            ApplicationView      app     = new ApplicationView();
            ApplicationViewModel context = ApplicationViewModel.Instance;

            app.DataContext = context;
            app.Show();
        }
        public DisplayMessageViewModel(Message message, bool wasSent)
        {
            Name         = "DisplayMessage";
            _db          = MyDbContext.Create();
            this.wasSent = wasSent;
            messageId    = message.Id;
            var user = _db.Users.Where(n => n.Name == RunTimeInfo.Instance.Username).SingleOrDefault();

            if (user != null)
            {
                userId = user.Id;
                if (user.IsAdmin)
                {
                    _db.Messages.Find(messageId).AdminSeen = true;
                }
                else
                {
                    _db.Messages.Find(messageId).ClientSeen = true;
                }
                _db.SaveChanges();
            }
            MessageContent = message.Content;
            AuthorFullName = message.AuthorFullName;
            Title          = message.Title;
        }
 public CreateMessageViewModel(bool wasSent)
 {
     Name                   = "CreateMessage";
     _db                    = MyDbContext.Create();
     this.wasSent           = wasSent;
     ReplyingMessageContent = "";
 }
        public ClientPanelViewModel()
        {
            _db = MyDbContext.Create();
            var user = _db.Users.Where(n => n.Name == RunTimeInfo.Instance.Username).SingleOrDefault();

            if (user != null)
            {
                userId        = user.Id;
                UserName      = user.Name;
                Surname       = user.Surname;
                Email         = user.Email;
                StreetName    = user.StreetName;
                City          = user.City;
                PostalCode    = user.PostalCode;
                PhoneNumber   = user.PhoneNumber;
                PaymentMethod = user.PaymentMethod;
            }

            ordPrdPage = 1;
            productsAndOrdersPageSize = 10;
            isNextOrdPrdPageValid     = false;
            ObservedProducts          = new ObservableCollection <Product>();
            Orders         = new ObservableCollection <Order>();
            DisplayedItems = ClientPanelDisplayedItems.Orders;
            LoadOrders();
        }
Ejemplo n.º 5
0
        public CartViewModel()
        {
            _db = MyDbContext.Create();

            ProductsInCart  = new ObservableCollection <Product>();
            _productsInCart = new List <Product>();

            LoadData();
        }
Ejemplo n.º 6
0
        public ClientListViewModel()
        {
            _db = MyDbContext.Create();

            Users  = new ObservableCollection <User>();
            _users = new List <User>();

            _pageSize = 6;
            Page      = 1;

            LoadData();
        }
        public ProductListViewModel()
        {
            _db = MyDbContext.Create();

            ChosenCategories = new List <Category>();
            Products         = new ObservableCollection <Product>();
            Categories       = new ObservableCollection <Category>();
            _products        = new List <Product>();

            _pageSize = 10;
            Page      = 1;

            LoadData();
        }
        public CreateMessageViewModel(int messageId, bool wasSent)
        {
            Name           = "CreateMessage";
            this.messageId = messageId;
            this.wasSent   = wasSent;
            _db            = MyDbContext.Create();
            var message = _db.Messages.Find(messageId);

            ReplyingMessageContent = message.Content;
            if ((message.Title.Substring(0, 3) != "Re:"))
            {
                Title = $"Re: {message.Title}";
            }
        }
 public ProductDetailsViewModel(int id)
 {
     Name = "Display";
     _db  = MyDbContext.Create();
     LoadProduct(id);
     Id                = _product.Id;
     ProductName       = _product.Name;
     Description       = _product.Description;
     Price             = _product.Price;
     Brand             = _product.Brand;
     Quantity          = _product.Quantity;
     Categories        = _product.Categories;
     ImagePath         = _product.ImagePath;
     ProductsViewModel = new ProductsViewModel();
 }
Ejemplo n.º 10
0
        public OrderViewModel()
        {
            _db = MyDbContext.Create();

            var user = _db.Users.Where(n => n.Name == RunTimeInfo.Instance.Username).SingleOrDefault();

            if (user != null)
            {
                FirstName     = user.Name;
                Surname       = user.Surname;
                StreetName    = user.StreetName;
                City          = user.City;
                PostalCode    = user.PostalCode;
                PhoneNumber   = user.PhoneNumber;
                PaymentMethod = user.PaymentMethod;
            }

            OrderedProducts  = new ObservableCollection <Product>();
            _orderedProducts = new List <Product>();

            LoadData();
            CountFinalPrice();
        }
Ejemplo n.º 11
0
        public MessageBoxViewModel()
        {
            _db = MyDbContext.Create();
            var user = _db.Users.Where(n => n.Name == RunTimeInfo.Instance.Username).SingleOrDefault();

            if (user != null)
            {
                userId = user.Id;
                if (!user.IsAdmin)
                {
                    CanCreate = true;
                }
                else
                {
                    CanCreate = false;
                }
            }
            messagePage        = 1;
            messagePageSize    = 14;
            isNextMsgPageValid = false;
            Messages           = new ObservableCollection <Message>();
            DisplayedMessages  = MessageDisplay.Received;
            LoadMessages();
        }
Ejemplo n.º 12
0
 public RegisterViewModel()
 {
     _db = MyDbContext.Create();
 }
 public HomeController()
 {
     context = MyDbContext.Create();
 }
 public MyController()
 {
     context        = MyDbContext.Create();
     firebaseClient = new FirebaseClient("https://luu-data.firebaseio.com/");
 }
Ejemplo n.º 15
0
 public UnitOfWork()
 {
     _db = MyDbContext.Create();
 }
Ejemplo n.º 16
0
 public LoginViewModel()
 {
     _db = MyDbContext.Create();
 }