コード例 #1
0
        private async Task DeleteStaffs(StaffTableViewModel staff)
        {
            var a = "";

            if (await _pageService.DisplayAlert("Warning", $"Are you sure you want to delete{staff.StaffID}?", "Yes", "No"))
            {
                Staffs.Remove(staff);
                var userStaff = await _staffStore.GetStaffs(staff.Id);

                await _staffStore.DeleteStaff(userStaff);
            }
        }
コード例 #2
0
 public IActionResult DeleteStaff(string Id)
 {
     try
     {
         var result = _IStaff.DeleteStaff(Id);
         return(Ok(result));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #3
0
        static void Main(string[] args)
        {
            var    env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
            string currentDirectory = Directory.GetCurrentDirectory();
            var    builder          = new ConfigurationBuilder()
                                      .AddJsonFile(currentDirectory + $"\\appSettings.Development.json", true, true);
            var    config = builder.Build();
            string managerClassTypeString = config["StorageType"];

            //get the type of the class
            Type managerClassType = Type.GetType("StaffLibrary." + managerClassTypeString + ",StaffLibrary", true);

            //build an instance of the class
            IStaff manager = Activator.CreateInstance(managerClassType) as IStaff;
            int    yourChoice;
            var    subjectForTeaching = config["SubjectList"];

            if (!string.IsNullOrEmpty(subjectForTeaching))
            {
                Teaching.SubjectList = subjectForTeaching;
            }
            do
            {
                DisplayStaffOpMenu();
                Console.Write("Enter your choice:");
                yourChoice = int.Parse(Console.ReadLine());
                switch (yourChoice)
                {
                case 1:


                    Staff StaffObj = AddDetails(manager);
                    manager.AddStaff(StaffObj);
                    break;

                case 2:
                    DisplayStaffMenu();
                    int choice;
                    choice = int.Parse(Console.ReadLine());
                    //DisplayStaffList(choice);
                    DisplayAllStaff(manager.GetEachStaffType(choice));
                    //DisplayAllStaff(manager.GetAllStaff());
                    break;

                case 3:
                    Console.WriteLine("Enter the Id to be searched");
                    int iD   = int.Parse(Console.ReadLine());
                    var item = manager.GetStaffByID(iD);
                    if (item != null)
                    {
                        DisplayStaff(item);
                    }
                    else
                    {
                        Console.WriteLine("Staff with id:" + iD + " does not exist");
                    }

                    break;

                case 4:
                    Console.WriteLine("Enter Staff Id which you want to delete:");
                    int  staffID = int.Parse(Console.ReadLine());
                    bool result  = manager.DeleteStaff(staffID);
                    if (result == true)
                    {
                        Console.WriteLine("Employee deleted");
                    }
                    else
                    {
                        Console.WriteLine("Employee with ID:" + staffID + " not found");
                    }
                    break;

                case 5:
                    UpdateDetails(manager);
                    break;

                case 6:
                    int          numberOfStaff, i;
                    List <Staff> staffList = new List <Staff>();
                    Console.WriteLine("Enter the number of records do you want to insert");
                    numberOfStaff = int.Parse(Console.ReadLine());
                    for (i = 0; i < numberOfStaff; i++)
                    {
                        Staff staffObj = AddDetails(manager);
                        staffList.Add(staffObj);
                    }
                    manager.BulkInsert(staffList);
                    break;

                case 7:
                    return;

                default:
                    Console.WriteLine("invalid choice");
                    break;
                }
            } while (true);
        }