コード例 #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);
 }