async Task Save()
        {
            if (String.IsNullOrWhiteSpace(Staff.staffID) &&
                String.IsNullOrWhiteSpace(Staff.firstName) &&
                String.IsNullOrWhiteSpace(Staff.accountType) &&
                String.IsNullOrWhiteSpace(Staff.idNumber) &&
                String.IsNullOrWhiteSpace(Staff.password))
            {
                await _pageService.DisplayAlert("Error", "Please enter All the Fields", "OK");

                return;
            }
            if (Staff.id == 0)
            {
                await _staffStore.AddStaff(Staff);

                StaffAdded?.Invoke(this, Staff);
            }
            else
            {
                await _staffStore.UpdateStaff(Staff);

                StaffUpdated?.Invoke(this, Staff);
            }
            await _pageService.PopModalAsync();
        }
示例#2
0
        public IActionResult AddStaff([FromBody] PostModel inStaff)
        {
            StaffDetails obj = JsonConvert.DeserializeObject <StaffDetails>(inStaff.Key);

            try
            {
                var result = _IStaff.AddStaff(obj);
                return(Ok(result));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#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);
        }