Пример #1
0
 public JsonResult ByKeyAsJSON(string id)
 {
     try
     {
         var template = templaterepo.First(c => c.Key == id);
         return(Json(template, JsonRequestBehavior.AllowGet));
     }
     catch
     {
         //is there a better thing to pass back.  Perhaps json {"error": "no template found"} or some such
         return(Json(null, JsonRequestBehavior.AllowGet));
     }
 }
Пример #2
0
        //we are going to try to send out an invite, and will return true if all seems to go well
        public bool sendInvite(Invite invite)
        {
            try
            {
                //try to send message
                string key = "Invite_Friend";
                MongoRepository <Template> templaterepo = new MongoRepository <Template>();
                Template template = templaterepo.First(c => c.Key == key);

                //public bool smtpMailHelper(MailAddressCollection toCollection, MailAddressCollection ccCollection, string subject, string body, bool isHtml, MailAddress from, string priority)
                string subject = decodedTemplate(invite, template.Subject);
                string body    = decodedTemplate(invite, template.Body);

                //only passing a single email, but our helper is expecitng a collection
                MailAddressCollection toCollection = new MailAddressCollection();
                toCollection.Add(new MailAddress(invite.SendTo));

                MailAddressCollection ccCollection = new MailAddressCollection();

                //public bool smtpMailHelper(MailAddressCollection toCollection, MailAddressCollection ccCollection, string subject, string body, bool isHtml, MailAddress from, string priority)


                return(smtpMailHelper(toCollection, ccCollection, subject, body, true, new MailAddress(invite.SentBy_Email), "Normal"));
            }
            catch
            {
                return(false);
            }
        }
Пример #3
0
        //
        // GET: /Home/DualGraph/
        public ActionResult DualGraph(string id)
        {
            MongoRepository <Template> templaterepo = new MongoRepository <Template>();

            Template template = new Template()
            {
                Subject = "",
                Body    = ""
            };

            string key = "DualGraph_" + id;

            if (hasKey(key))
            {
                template = templaterepo.First(c => c.Key == key);
            }

            return(View(template));
        }
Пример #4
0
        //
        // GET: /Home/
        public ActionResult Index()
        {
            MongoRepository <Template> templaterepo = new MongoRepository <Template>();

            ViewBag.isAdmin = isInRole(User.Identity.Name, "Admin");


            Template template = null;
            string   key      = "Welcome";

            if (templaterepo.Exists(c => c.Key == key))
            {
                template = templaterepo.First(c => c.Key == key);
            }
            else
            {
                template = new Template()
                {
                    Subject = "Welcome",
                    Body    = "A custom Welcome page has not been created for this <strong>application</strong> - you can create one under Admin - Templates"
                };
            }
            return(View(template));
        }
Пример #5
0
 public Guid LogInAndReturnUID(string adminName, string adminPassword)
 {
     return(Guid.Parse(repo.First(x => x.AdminName == adminName && x.AdminPassword == adminPassword && x.AdminState == 1).AdminID));
 }
Пример #6
0
        static void Main(string[] args)
        {
            //Add customers
            var john = new Customer()
            {
                FirstName = "John", LastName = "Doe"
            };
            var jane = new Customer()
            {
                FirstName = "Jane", LastName = "Doe"
            };
            var jerry = new Customer()
            {
                FirstName = "Jerry", LastName = "Maguire"
            };

            customerrepo.Add(new[] { john, jane, jerry });

            //Show contents of DB
            DumpData();

            //Update customers
            john.FirstName = "Johnny";  //John prefers Johnny
            customerrepo.Update(john);

            jane.LastName = "Maguire";  //Jane divorces John and marries Jerry
            customerrepo.Update(jane);

            //Delete customers
            customerrepo.Delete(jerry.Id);  //Jerry passes away

            //Add some products to John and Jane
            john.Products.AddRange(new[] {
                new Product()
                {
                    Name = "Fony DVD Player XY1299", Price = 35.99M
                },
                new Product()
                {
                    Name = "Big Smile Toothpaste", Price = 1.99M
                }
            });
            jane.Products.Add(new Product()
            {
                Name = "Life Insurance", Price = 2500
            });
            customerrepo.Update(john);
            customerrepo.Update(jane);
            //Or, alternatively: customerrepo.Update(new [] { john, jane });

            //Show contents of DB
            DumpData();

            //Finally; demonstrate GetById and First
            var mysterycustomer1 = customerrepo.GetById(john.Id);
            var mysterycustomer2 = customerrepo.First(c => c.FirstName == "Jane");

            Console.WriteLine("Mystery customer 1: {0} (having {1} products)",
                              mysterycustomer1.FirstName, mysterycustomer1.Products.Count);
            Console.WriteLine("Mystery customer 2: {0} (having {1} products)",
                              mysterycustomer2.FirstName, mysterycustomer2.Products.Count);

            //Delete all customers
            customerrepo.DeleteAll();

            //Halt for user
            Console.WriteLine("Press any key...");
            Console.ReadKey();
        }
Пример #7
0
 /// <summary>
 /// get the identity of the user by user's name
 /// </summary>
 /// <param name="userName">the name of user</param>
 /// <returns></returns>
 public string GetUIDbyUserName(string userName)
 {
     return(repo.First(x => x.UserName == userName).Id);
 }
Пример #8
0
 public void GetCandidate(string id)
 {
     _candidateRepository.First(candidate => candidate.Id == id);
 }