public UserFamilyViewModel(UserFamily userFamily) { UserId = userFamily.UserId; FamilyId = userFamily.FamilyId; IsPending = userFamily.IsPending; IsAdmin = userFamily.IsAdmin; }
// POST: api/UserFamilies public UserFamilyViewModel Post(UserFamily userFamily, string familyId = null, string userId = null) { UserFamily toUpdate = null; if (familyId != null && userId != null) { toUpdate.UserId = userFamily.UserId; toUpdate.FamilyId = userFamily.FamilyId; toUpdate.IsPending = userFamily.IsPending; toUpdate.IsAdmin = userFamily.IsAdmin; } else db.UserFamilies.Add(userFamily); db.SaveChanges(); return new UserFamilyViewModel(toUpdate ?? userFamily); }