public bool SaveSignup(Signup signup) { var existingSignup = GetSignup(signup.SignupId); if (existingSignup == null) { var newSignupId = CreateSignup(signup); return(newSignupId > 0); } #region Here we may user AutoMapper existingSignup.Activity = signup.Activity; existingSignup.Comments = signup.Comments; existingSignup.User = signup.User; #endregion var retValue = _dbCtx.SaveChanges(); if (retValue == 0) { _dbCtx.Entry(signup).State = EntityState.Modified; } return(retValue == 0); }
public bool SaveUser(User user) { var existingUser = GetUser(user.Email); if (existingUser == null) { var newUserId = CreateUser(user); return(newUserId > 0); } #region Here we may user AutoMapper existingUser.FirstName = user.FirstName; existingUser.LastName = user.LastName; existingUser.Email = user.Email; #endregion var retValue = _dbCtx.SaveChanges(); if (retValue == 0) { _dbCtx.Entry(user).State = EntityState.Modified; } return(retValue == 0); }