Example #1
0
        public async Task <IActionResult> SignIn(int id)
        {
            string s = HttpContext.Request.Host.Value;

            if (!User.Identity.IsAuthenticated)
            {
                return(Challenge(new AuthenticationProperties {
                    RedirectUri = "/signin"
                }, "Google"));
            }
            else
            {
                //save the user an dthen redirect it back to the UI
                // first get the current user in the User formamt...

                UserInfo currentUser             = getLoggedInUserInfo();
                UserInfo currentUserObjectFromDB = (UserInfo)(dynamic)await _repository.GetFirstDocAsync("usergoogid='" + currentUser.usergoogid + "'");

                {
                    if (currentUserObjectFromDB == null)
                    {
                        //    /// this means that the user is authenticated but yet has not been saved in the system.
                        //    /// So, save the user record in teh system.
                        currentUser.regStatus   = USER_RECORD_SAVED;
                        currentUserObjectFromDB = (UserInfo)(dynamic)await _repository.CreateAsync(currentUser);

                        // save one dummy record fror one contact
                    }
                    DocdbRepository <Contact> contactsRepo = new DocdbRepository <Contact>();
                    contactsRepo.Initialize("Contacts");
                    Contact c1 = (dynamic)await contactsRepo.GetFirstDocAsync("usergoogid='" + currentUser.usergoogid + "'");

                    if (c1 == null)
                    {
                        Contact c = new Contact()
                        {
                            //id = ,
                            usergoogid  = currentUser.usergoogid,
                            first_name  = "ZZZZZ-Dummy-first-name",
                            last_name   = "ZZZZZ-Dummy-last-name",
                            email       = "*****@*****.**",
                            subject     = "ZZZZZ-Dummy-subject",
                            description = "ZZZZZ-Dummy-description"
                        };
                        await contactsRepo.CreateAsync(c);
                    }
                }
                return(Redirect("/"));
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            var repo = new DocdbRepository <Product>();

            repo.Initialize();
            var prod = new Product
            {
                Id          = "alfa",
                Name        = "pc",
                Description = "laptop new",
                Price       = 123.76
            };

            repo.CreateItemAsync(prod).Wait();
            Console.WriteLine("Hello World!");
        }