public int AddUser(ApiUser user) { if (user == null) { throw new ArgumentNullException("user"); } var entityUser = user.ToEntity(); using (rebtelEntities container = new rebtelEntities()) { container.Users.Add(entityUser); container.SaveChanges(); return entityUser.Id; } }
public int AddUser(ApiUser user) { if (user == null) { throw new ArgumentNullException("user"); } var entityUser = user.ToEntity(); using (serviceEntities container = new serviceEntities()) { //If I where to use url-friendly-name I would have done this or maybe have a unique contstraint on the colmn and then add the count in the catch: //int count = container.Users.Where(u => u.FirstName == entityUser.FirstName && u.LastName == entityUser.LastName).Count(); //entityUser.urlFriendly = Utilities.toUrlFriendlyIndentifier(entityUser.FirstName + "-" + entityUser.LastName); //entityUser.urlFriendly += count > 0 ? count.ToString() : ""; container.Users.Add(entityUser); container.SaveChanges(); return entityUser.Id; } }