public async Task <IActionResult> AddOrEdit(SocialMedia model) { var header = this.Request.Headers["sec-fetch-site"]; if (header == "none") { return(RedirectToAction("Index", "Advertisement")); } bool update = true; SocialMedia entity = null; if (ModelState.IsValid) { User currentUser = await signInManager.UserManager.GetUserAsync(this.User); if (model.Id == 0) { entity = new SocialMedia(); entity.UserId = currentUser.Id; update = false; } else { entity = db.SocialMedias.FirstOrDefault(s => s.Id == currentUser.SocialMedia.Id); } entity.Facebook = model.Facebook; entity.Behance = model.Behance; entity.Dribbble = model.Dribbble; entity.Github = model.Github; entity.Linkedin = model.Linkedin; entity.Twitter = model.Twitter; entity.Youtube = model.Youtube; entity.Instagram = model.Instagram; entity.Pintrest = model.Pintrest; if (update) { db.Update <SocialMedia>(entity); toastNotification.AddSuccessToastMessage("Social Media Link Updated !", new NotyOptions { Theme = "metroui", Timeout = 1500, Layout = "topCenter" }); } else { await db.AddAsync <SocialMedia>(entity); toastNotification.AddSuccessToastMessage("Social Media Link Added !", new NotyOptions { Theme = "metroui", Timeout = 1500, Layout = "topCenter" }); } await db.SaveChangesAsync(); } return(PartialView("_AddOrEdit", model)); }
public async Task <IActionResult> Create(Education model) { if (ModelState.IsValid) { User currentUser = await signInManager.UserManager.GetUserAsync(this.User); model.UserId = currentUser.Id; await db.AddAsync <Education>(model); await db.SaveChangesAsync(); toastNotification.AddSuccessToastMessage("Education experience added !", new NotyOptions { Theme = "metroui", Timeout = 1500, Layout = "topCenter" }); } return(PartialView("_Create", model)); }
public async Task <IActionResult> Create(LanguageViewModel model) { if (ModelState.IsValid) { User currentUser = await signInManager.UserManager.GetUserAsync(this.User); Language entity = new Language(); entity.UserId = currentUser.Id; entity.ProfeciencyLevel = model.language.ProfeciencyLevel; entity.LanguageName = model.language.LanguageName; await db.AddAsync <Language>(entity); await db.SaveChangesAsync(); toastNotification.AddSuccessToastMessage("Language Added !", new NotyOptions { Theme = "metroui", Timeout = 1500, Layout = "topCenter" }); } return(PartialView("_Create", model)); }