public ActionResult Create(int? UserId, int? CanEmailFor)
        {
            if (!UserId.HasValue || !CanEmailFor.HasValue)
                return RedirectShowError("missing id");
            var user1 = DbUtil.Db.Users.SingleOrDefault(uu => uu.UserId == UserId);
            if (user1 == null)
                return RedirectShowError("no such user " + UserId);
            var user2 = DbUtil.Db.Users.SingleOrDefault(uu => uu.UserId == CanEmailFor);
            if (user2 == null)
                return RedirectShowError("no such user " + CanEmailFor);
            var u = DbUtil.Db.UserCanEmailFors.SingleOrDefault(uu => uu.UserId == UserId && uu.CanEmailFor == CanEmailFor);
            if (u != null)
                return RedirectShowError("already exists");

            u = new UserCanEmailFor { UserId = UserId.Value, CanEmailFor = CanEmailFor.Value };
            DbUtil.Db.UserCanEmailFors.InsertOnSubmit(u);
            DbUtil.Db.SubmitChanges();
            return RedirectToAction("Index");
        }
Example #2
0
 private void detach_UsersWhoCanEmailForMe(UserCanEmailFor entity)
 {
     this.SendPropertyChanging();
     entity.Boss = null;
 }
Example #3
0
 private void detach_UsersICanEmailFor(UserCanEmailFor entity)
 {
     this.SendPropertyChanging();
     entity.Assistant = null;
 }
Example #4
0
 private void detach_UsersWhoCanEmailForMe(UserCanEmailFor entity)
 {
     this.SendPropertyChanging();
     entity.Boss = null;
 }
Example #5
0
 private void detach_UsersICanEmailFor(UserCanEmailFor entity)
 {
     this.SendPropertyChanging();
     entity.Assistant = null;
 }