Beispiel #1
0
        public void Delete(Project model)
        {
            var projectToDelete = _ctx.Projects.FirstOrDefault(x => x.ProjectName == model.ProjectName);

            _ctx.Projects.Remove(projectToDelete);
            _ctx.SaveChanges();
        }
Beispiel #2
0
 public async Task <bool> CreateUserProfile(UserProfile userToCreate)
 {
     try
     {
         _userProfileContext.UserProfiles.Add(userToCreate);
         _userProfileContext.SaveChanges();
         flag = true;
         return(await Task.FromResult(flag));
     }
     catch
     {
         flag = false;
         return(await Task.FromResult(flag));
     }
 }
        public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model, string returnUrl)
        {
            string provider = null;
            string providerUserId = null;

            if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId))
            {
                return RedirectToAction("Manage");
            }

            if (ModelState.IsValid)
            {
                // Insert a new user into the database
                using (var db = new UserProfileDbContext())
                {
                    UserProfile user = db.UserProfile.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower());
                    // Check if user already exists
                    if (user == null)
                    {
                        // Insert name into the profile table
                        db.UserProfile.Add(new UserProfile { UserName = model.UserName });
                        db.SaveChanges();

                        OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName);
                        OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false);

                        return RedirectToLocal(returnUrl);
                    }
                    else
                    {
                        ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name.");
                    }
                }
            }

            ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName;
            ViewBag.ReturnUrl = returnUrl;
            return View(model);
        }
 public void Add(UserProfile model)
 {
     _ctx.UserProfiles.Add(model);
     _ctx.SaveChanges();
 }
 public void Add(Contact model)
 {
     _ctx.Contacts.Add(model);
     _ctx.SaveChanges();
 }
Beispiel #6
0
 public void Add(UserServices model)
 {
     _ctx.Services.Add(model);
     _ctx.SaveChanges();
 }
Beispiel #7
0
 public void Add(Education model)
 {
     _ctx.Educations.Add(model);
     _ctx.SaveChanges();
 }