Example #1
0
        private User CreateUser(User userObject)
        {
            try
            {
                model.Users.Add(userObject);
                model.SaveChanges();

            }
            catch (Exception ex)
            {

                throw ex;
            }
            return userObject;
        }
Example #2
0
        private User GetOrCreateUser(string userEmail,string userName,string location,string photoUrl)
        {
            var userObject = model.Users.Where(m => m.Email == userEmail).ToList();
            if (userObject.Count>0)
                return userObject.First();

            var userObjectToAdd = new User();
            userObjectToAdd.ID = Guid.NewGuid().ToString();
            userObjectToAdd.Location = location;
            userObjectToAdd.Name = userName;
            userObjectToAdd.PhotoUrl = photoUrl;
            userObjectToAdd.Email = userEmail;
            return CreateUser(userObjectToAdd);
        }