public async Task <ActionResult <AllStaff> > PostAllStaff(AllStaff allStaff)
        {
            _context.AllStaff.Add(allStaff);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAllStaff", new { id = allStaff.Id }, allStaff));
        }
 internal void ChangeCurrentStaff(int selectedValue)
 {
     CurrentStaff = AllStaff.Find(g => g.Id == selectedValue);
     AllGroups.ForEach(x => x.Check(CurrentStaff.GroupIds));
     OnPropertyChanged("CurrentStaff");
     OnPropertyChanged("CurrentGroup");
 }
        public async Task <IActionResult> PutAllStaff(int id, AllStaff allStaff)
        {
            if (id != allStaff.Id)
            {
                return(BadRequest());
            }

            _context.Entry(allStaff).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AllStaffExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #4
0
        /// <summary>
        /// Handler executed when CardDeleteCmd command is invoked
        /// </summary>
        private async void OnCardDeleteCmd()
        {
            if (_selectedYtChannel == null)
            {
                return;
            }

            //let's set up a little MVVM, cos that's what the cool kids are doing:
            var view = new DialogRemoveChannel()
            {
                DataContext = this
            };

            //show the dialog
            bool result = (bool)await DialogHost.Show(view, "RootDialog");

            if (result)
            {
                YtChannels.Remove(_selectedYtChannel);                  // Remove videos from our colection

                this.OnFilterChanged();                                 // Refresh collection source view

                AllStaff.Refresh();

                _yupRepository.RemoveChannel(_selectedYtChannel);   // Remove channel from repository
                _yupRepository.SaveRepository();                    // Save repo

                _eventBus.RaiseEvent(EventOnBus.channelRemoved,     // Raie event to notify the remaining components
                                     this, new EventBusArgs()
                {
                    Item = _selectedYtChannel
                });
            }
        }
Beispiel #5
0
    static void Main()
    {
        Staff[] AllStaffArray = new Staff[3]
        {
            new Staff("Іван", "Калита"),
            new Staff("Люба", "Головач"),
            new Staff("Лена", "Калуга"),
        };

        AllStaff staffList = new AllStaff(AllStaffArray);

        foreach (Staff s in staffList)
        {
            Console.WriteLine(s.firstName + " " + s.lastName);
        }
    }
        private void reloadData()
        {
            try
            {
                AllStaff  = dbContext.Staffs.Include(s => s.StaffGroups).ToList();
                AllGroups = dbContext.Groups.Include(g => g.StaffGroups).ToList();
            }
            catch (EntityCommandExecutionException e)
            {
                Console.WriteLine(e);
                throw;
            }

            if (AllStaff.Count() == 0)
            {
                AllStaff.Add(new Staff()
                {
                    LastName   = "Adekoya",
                    FirstName  = "Adekunle",
                    OtherNames = "Adeniyi",
                    Dob        = new DateTime(1982, 8, 9),
                    Gender     = "Male",
                    CreatedAt  = DateTime.Today,
                    UpdatedAt  = DateTime.Now,
                    // StaffGroups = new List<StaffGroup>() { new StaffGroup(){GroupId = 3, StaffId  =1} }
                });
                AllStaff.Add(new Staff()
                {
                    LastName   = "Goriowo",
                    FirstName  = "Omolade",
                    OtherNames = "H",
                    Dob        = new DateTime(1992, 1, 5),
                    Gender     = "Female",
                    CreatedAt  = DateTime.Today,
                    UpdatedAt  = DateTime.Now
                });
            }


            OnPropertyChanged("AllGroups");
            OnPropertyChanged("AllStaff");
        }
Beispiel #7
0
        protected void updateTable()
        {
            List <AllStaff> allStaffs    = new List <AllStaff>();
            List <AllStaff> filterStaffs = new List <AllStaff>();

            foreach (Staff staff in db.staffs)
            {
                AllStaff allStaff = new AllStaff(staff.name, staff.email, staff.password, staff.role);
                allStaffs.Add(allStaff);
            }

            foreach (Salesman salesman in db.salesmen)
            {
                AllStaff allStaff = new AllStaff(salesman.name, salesman.email, "", "Salesman");
                allStaffs.Add(allStaff);
            }

            if (chkGeneral.Checked)
            {
                filterStaffs.AddRange(allStaffs.Where(x => x.role == "General Staff").ToList());
            }
            if (chkInventory.Checked)
            {
                filterStaffs.AddRange(allStaffs.Where(x => x.role == "Inventory Clerk").ToList());
            }
            if (chkManager.Checked)
            {
                filterStaffs.AddRange(allStaffs.Where(x => x.role == "Manager").ToList());
            }
            if (chkSalesman.Checked)
            {
                filterStaffs.AddRange(allStaffs.Where(x => x.role == "Salesman").ToList());
            }

            filterStaffs = filterStaffs.Where(x => x.name.Contains(txtName.Text)).OrderBy(x => x.role).ToList();

            gvStaff.DataSource = filterStaffs;
            gvStaff.DataBind();
        }
        /// <summary>
        /// Register new employee in AllStaff. Returns true if successful (non duplicate).
        /// </summary>
        /// <param name="employeeID"></param>
        /// <param name="name"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        static public bool RegisterAllStaff(int employeeID, string name, string username, string password, int roleID, int departmentID)
        {
            try
            {
                var db = Connection();

                //check if username already exists
                var query = from staff in db.AllStaffs where staff.Username == username select staff;

                if (query.Any())
                {
                    //if username exists, exit
                    return(false);
                }
                else
                {
                    //if username not taken, create account
                    AllStaff newStaff = new AllStaff
                    {
                        EmployeeID   = employeeID,
                        Name         = name,
                        Username     = username,
                        Password     = password,
                        RoleID       = roleID,
                        DepartmentID = departmentID
                    };

                    db.AllStaffs.InsertOnSubmit(newStaff);
                    db.SubmitChanges();

                    return(true);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return((bool)GetDefaultReturn(typeof(bool)));
            }
        }