Esempio n. 1
0
 public ActionResult Index()
 {
     using (var dc = new RapDbContext()) {
         var model = new HomeViewModel {
             MyBookingCount = dc.Bookings.Count(x => x.User.UserName.Equals(this.User.Identity.Name) && x.DateBegin >= DateTime.Today),
             Resources = dc.Resources.OrderBy(x => x.Name).ToArray(),
             Messages = dc.Messages.Include("User").OrderByDescending(x => x.DateCreated).Take(3).ToArray()
         };
         return View(model);
     }
 }
Esempio n. 2
0
        public void InitializeApplicationData()
        {
            // Set runtime options; this also creates ~/App_Data/ folder
            RuntimeOptions.Current.ApplicationTitle = this.ApplicationTitle;
            RuntimeOptions.Current.Save();

            // Create new resource; this also creates the database
            using (var dc = new RapDbContext()) {
                dc.Resources.Add(new Resource { Name = this.FirstResourceName });
                dc.SaveChanges();
            }

            // Update parameters of user 'Administrator'
            var admin = Membership.GetUser("Administrator", false);
            var tempPassword = admin.ResetPassword();
            admin.ChangePassword(tempPassword, this.AdministratorPassword);
            admin.Email = this.AdministratorEmail;
            Membership.UpdateUser(admin);
        }