Esempio n. 1
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            var staff = context.staffs.Create();

            staff.username     = usernameTextBox.Text.Trim();
            staff.password     = passwordTextBox.Password.Trim();
            staff.isAdmin      = false;
            staff.ime          = nameTextBox.Text.Trim();
            staff.prezime      = surnameTextBox.Text.Trim();
            staff.zaposlenOd   = DateTime.Now;
            staff.brojTelefona = phoneTextBox.Text.Trim();
            staff.plata        = Decimal.Parse(paycheckTextBox.Text.Trim());
            staff.isActive     = 1;
            staff.isAdmin      = false;
            var result = context.staffs.Where(a => a.username.Equals(staff.username));

            if (result.Count() > 0)
            {
                takenLabel.Visibility = Visibility.Visible;
            }
            else
            {
                context.staffs.Add(staff);
                context.SaveChanges();
                this.Close();
            }
        }
        private void Delete_Staff(object sender, RoutedEventArgs e)
        {
            var curr = context.staffs.Find(currUser.id);

            curr.isActive = 0;
            context.SaveChanges();
            currUser = null;
            initialiseStaff();
            staffInfoLabel.Content  = "";
            deleteButton.Visibility = Visibility.Hidden;
            editButton.Visibility   = Visibility.Hidden;
        }
Esempio n. 3
0
 private Task <Grid> addOrder(OrderModel om)
 {
     return(new Task <Grid>(() =>
     {
         order o = context.orders.Create();
         o.size = om.size;
         o.type = om.type;
         o.staffId = om.staffId;
         o.location = om.location;
         o.isActive = 1;
         foreach (var id in om.drinkIds)
         {
             o.drinks.Add(context.drinks.Find(id));
         }
         foreach (var id in om.sideIds)
         {
             o.sides.Add(context.sides.Find(id));
         }
         var or = context.orders.Add(o);
         context.SaveChanges();
         Grid g = createGrid(or.id);
         return g;
     }));
 }