예제 #1
0
 public ActionResult AllUsers()
 {
     var db = new TimecraftDb();
     var allUsers = from u in db.Users
                    select u;
     return View(allUsers);
 }
예제 #2
0
        public ActionResult Detail(long id, IUser user)
        {
            var timecraftDb = new TimecraftDb();
            var business = timecraftDb.Business.Include("Administrator").SingleOrDefault(b => b.Id == id);
            if (business == null)
                return new HttpNotFoundResult();

            return View(business);
        }
예제 #3
0
        public ActionResult EditUserInfo(UserInfo userInfo, IUser user)
        {
            if (!ModelState.IsValid)
                return View(userInfo);

            var timecraftDb = new TimecraftDb();
            var model = timecraftDb.Users.Single(u => u.Id == user.Id);
            model.Email = userInfo.Email;
            model.FirstName = userInfo.FirstName;
            model.LastName = userInfo.LastName;
            timecraftDb.SaveChanges();

            return Redirect(Url.Action("Index"));
        }
예제 #4
0
        public ActionResult Create(BusinessInfo businessInfo, IUser user)
        {
            if (!ModelState.IsValid)
                return View(businessInfo);

            var timecraftDb = new TimecraftDb();

            var admin = timecraftDb.Users.Single(u => u.Id == user.Id);
            var business = new Business
            {
                Name = businessInfo.Name,
                Administrator = admin,
            };
            timecraftDb.Business.Add(business);
            timecraftDb.SaveChanges();

            return Redirect(Url.Action("Detail", new {id = business.Id}));
        }
예제 #5
0
 public ActionResult Index(IUser signedInUser)
 {
     var model = new TimecraftDb().Users.Single(u => u.Id == signedInUser.Id);
     return View(model);
 }
예제 #6
0
 public ActionResult EditUserInfo(IUser user)
 {
     var model = new TimecraftDb().Users.Single(u => u.Id == user.Id);
     return View(model);
 }