Exemplo n.º 1
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"));
        }
Exemplo n.º 2
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}));
        }