Пример #1
0
        public async Task <IActionResult> SignIn(int id)
        {
            var result = await AdminApplication.GetById(id);

            string tokenResult = string.Empty;

            if (result != null)
            {
                var claims = new ClaimsIdentity(new Claim[]
                {
                    new Claim("email", "*****@*****.**"),
                    new Claim(Constant.UserId, id.ToString())
                });

                var tokenHandler = new JwtSecurityTokenHandler();

                var encryptionKey   = Configuration["Jwt:Encryptionkey"];
                var key             = Encoding.ASCII.GetBytes(encryptionKey);
                var tokenDescriptor = new SecurityTokenDescriptor
                {
                    Issuer             = Configuration["Jwt:Issuer"],
                    Subject            = claims,
                    Audience           = Configuration["Jwt:Audience"],
                    Expires            = DateTime.Now.AddMinutes(Convert.ToDouble(Configuration["Jwt:ExpiryTimeInMinutes"])),
                    SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
                };

                SecurityToken token = tokenHandler.CreateToken(tokenDescriptor);
                tokenResult = tokenHandler.WriteToken(token);
            }
            return(Ok(new
            {
                token = tokenResult
            }));
        }
Пример #2
0
        public async Task <Admin> Get(int id)
        {
            if (id == 5)
            {
                throw  new Exception("not found");
            }
            //  var res = HttpContext.Items["UserID"];
            var result = await AdminApplication.GetById(id);

            return(result);
        }
        public async Task Insert()
        {
            var admin = new Admin()
            {
                CreatedBy = 5,
                FirstName = DateTime.Now.Second + " - US",
                RowState  = EntityState.New
            };

            var user = new User()
            {
                CreatedBy = 5,
                FirstName = DateTime.Now.Second + " - US",
                RowState  = EntityState.New
            };
            await AdminApplication.SaveAdminUser(admin, user);
        }
Пример #4
0
        public void AcceptAdminApplication()
        {
            bool isInt;
            int  output;

            List <AdminApplication> applications = GetApplications();

            if (applications == null || applications.Count == 0)
            {
                GUIHelper.Print("No applications found!", ConsoleColor.Red);
            }
            else
            {
                GUIHelper.Print("Please pick from the following applications for approval", ConsoleColor.Cyan);

                applications.ForEach(application => Console.WriteLine($"{application.Id}: {application.Email}"));

                Console.Write("Choice: ");

                string input = Console.ReadLine();
                isInt = int.TryParse(input, out output);

                if (isInt)
                {
                    AdminApplication chosenApplication = applications.FirstOrDefault(a => a.Id == output);

                    Person person = GetPerson(chosenApplication.Email);

                    using (IDbConnection cnn = new SQLiteConnection(Cnn))
                    {
                        cnn.Query <AdminApplication>("update People set IsAdmin = @value where email = @email", new { value = true, person.Email });
                        cnn.Query <AdminApplication>("delete from AdminApplications where email = @email", new { person.Email });
                    }

                    GUIHelper.Print("Application Approved!", ConsoleColor.Green);
                }
                else
                {
                    GUIHelper.Print("Please enter a valid number!", ConsoleColor.Red);
                }
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            IApplication application = new AdminApplication(new LinuxAPI());

            application.ShowCats();
            application.ShowCatByName("Barsic");

            Console.WriteLine();

            application = new AdminApplication(new MacOSAPI());
            application.ShowCats();
            application.ShowCatByName("Mursic");

            Console.WriteLine();

            application = new UserApplication(new WindowsAPI());
            application.ShowCats();
            application.ShowCatByName("Mursic");

            Console.ReadLine();
        }
Пример #6
0
        public AdminApplication GetApplication(string email)
        {
            using (IDbConnection cnn = new SQLiteConnection(Cnn))
            {
                Person person = GetPerson(email);

                AdminApplication application = null;

                if (person != null)
                {
                    application = cnn.QueryFirstOrDefault <AdminApplication>("select * from AdminApplications where Email=@email", new { email });

                    if (application == null)
                    {
                        GUIHelper.Print("You have no applications pending!", ConsoleColor.Red);
                        return(null);
                    }
                }

                GUIHelper.Print("You have 1 pending application!", ConsoleColor.Green);
                return(application);
            }
        }
Пример #7
0
        public void ApplyForAdmin(string email)
        {
            Person person = GetPerson(email);

            if (person != null)
            {
                AdminApplication existingApplication = GetApplication(person.Email);

                if (existingApplication == null)
                {
                    AdminApplication application = new AdminApplication()
                    {
                        PersonId = person.Id,
                        Email    = person.Email
                    };

                    using (IDbConnection cnn = new SQLiteConnection(Cnn))
                    {
                        cnn.Execute("insert into AdminApplications (PersonId, Email) values (@PersonId, @Email)", application);
                        GUIHelper.Print("Application Sent", ConsoleColor.Green);
                    }
                }
            }
        }
Пример #8
0
        public ActionResult CreateApp(AdminApplication ap)
        {
            Request r = new Models.Request();

            r.Travelers  = 1;
            r.Start_Date = ap.Start_Date;
            r.End_Date   = ap.End_Date;
            r.ST_ID      = 1;
            r.Addby      = User.Identity.Name;
            r.Country_ID = ap.Country_ID;
            r.Entry_ID   = ap.Entry_ID;
            r.addrequest();
            Client c = new Client();

            c.Email           = ap.Email;
            c.First_Name      = ap.First_Name;
            c.Last_Name       = ap.Last_Name;
            c.Passport_No     = ap.Passport_No;
            c.Passport_Issue  = ap.Passport_Issue;
            c.Passport_Expiry = ap.Passport_Expiry;
            c.Country_ID      = ap.Country_ID;
            c.Resident_ID     = ap.Resident_ID;
            c.Phone           = ap.Phone;
            c.DateOfBirth     = ap.DateOfBirth;
            c.Gender_ID       = ap.Gender_ID;
            c.Profession      = ap.Profession;
            c.PlaceOfBirth    = ap.PlaceOfBirth;
            c.add();
            //
            Application a = new Application();

            a.Client_ID = c.Client_ID;
            a.Comment   = " ";
            //Picture Work Goes Here.!
            string filename  = Path.GetFileNameWithoutExtension(ap.Passport_Scanpic.FileName);
            string extension = Path.GetExtension(ap.Passport_Scanpic.FileName);

            filename         = filename + c.Client_ID + extension;
            ap.Passport_Scan = "~/Image/" + filename;
            filename         = Path.Combine(Server.MapPath("~/Image/"), filename);
            ap.Passport_Scanpic.SaveAs(filename);
            a.Passport_Scan    = ap.Passport_Scan;
            a.Passport_Scanpic = ap.Passport_Scanpic;
            //PassportPhoto
            filename          = Path.GetFileNameWithoutExtension(ap.Passport_Photopic.FileName);
            extension         = Path.GetExtension(ap.Passport_Photopic.FileName);
            filename          = filename + c.Client_ID + extension;
            ap.Passport_Photo = "~/Image/" + filename;
            filename          = Path.Combine(Server.MapPath("~/Image/"), filename);
            ap.Passport_Photopic.SaveAs(filename);
            a.Passport_Photo    = ap.Passport_Photo;
            a.Passport_Photopic = ap.Passport_Photopic;
            a.Status_ID         = 1;
            a.R_ID = r.R_ID;
            //Visa
            if (ap.UKvisapic != null)
            {
                filename  = Path.GetFileNameWithoutExtension(ap.UKvisapic.FileName);
                extension = Path.GetExtension(ap.UKvisapic.FileName);
                filename  = filename + c.Client_ID + extension;
                ap.UKvisa = "~/Image/" + filename;
                filename  = Path.Combine(Server.MapPath("~/Image/"), filename);
                ap.UKvisapic.SaveAs(filename);
                a.UKvisapic = ap.UKvisapic;
                a.UKvisa    = ap.UKvisa;
            }
            //Ticket
            if (ap.Ticketpic != null)
            {
                filename  = Path.GetFileNameWithoutExtension(ap.Ticketpic.FileName);
                extension = Path.GetExtension(ap.Ticketpic.FileName);
                filename  = filename + c.Client_ID + extension;
                ap.Ticket = "~/Image/" + filename;
                filename  = Path.Combine(Server.MapPath("~/Image/"), filename);
                ap.Ticketpic.SaveAs(filename);
                a.Ticketpic = ap.Ticketpic;
                a.Ticket    = ap.Ticket;
            }

            //
            a.add();
            Payment p = new Models.Payment();

            p.Address          = ap.Address;
            p.Address2         = ap.Address2;
            p.Firstname        = ap.First_Name;
            p.Lastname         = ap.Last_Name;
            p.PostalCode       = ap.PostalCode;
            p.R_ID             = r.R_ID;
            p.town             = ap.Town;
            p.C_ID             = ap.Country_ID;
            p.Ad_ID            = 0;
            p.Currency_ID      = ap.Currency;
            p.Email            = ap.Email;
            p.Amount           = ap.Amount;
            Session["Payment"] = p;
            return(RedirectToAction("Payment"));
        }
 public AdminController()
 {
     adminApplication = new AdminApplication();
 }
Пример #10
0
 public void setCaller(AdminApplication caller)
 {
     this.caller = caller;
 }