/// <summary> /// Method for fetching Profile data of Blogger /// </summary> /// <param name="email"></param> /// <returns>profile object to Controller</returns> public VMAuthor Details(string email) { var user = db.Users.FirstOrDefault(m => m.Email == email); var skills = db.UserSkills.Where(m => m.UserId == user.UserId).ToList(); List <string> bloggerSkills = new List <string>(); List <string> bloggerCompany = new List <string>(); foreach (var item in skills) { if (item.Company == null) { bloggerSkills.Add(item.skill); } bloggerCompany.Add(item.Company); } var auther = new VMAuthor() { UserId = user.UserId, Name = user.Name, UserImage = user.ImageUrl, Email = user.Email, Mobile = user.Mobile, Description = user.Description, DOB = user.DateOfBirth.ToShortDateString(), Gender = user.Gender, Skills = bloggerSkills, Company = bloggerCompany, Rank = user.Rank }; return(auther); }
// GET: Author/Create public ActionResult Create() { try { var data = new VMAuthor(); return(View(data)); } catch (Exception ex) { return(View("Exception", ex)); } }
public ActionResult EditProfile(VMAuthor author) { if (ModelState.IsValid) { var result = _author.Edit(author); if (result) { return(RedirectToAction("AuthorProfile", "Author")); } } TempData["Message"] = "Fill all the Data Correctly !"; return(RedirectToAction("EditProfile", "Author")); }
/// <summary> /// Method for Editing The Blog. /// </summary> /// <param name="author"></param> /// <returns></returns> public bool Edit(VMAuthor author) { var data = db.Users.FirstOrDefault(m => m.UserId == author.UserId); if (data != null) { data.Name = author.Name; data.Mobile = author.Mobile; data.Description = author.Description; db.SaveChanges(); return(true); } return(false); }
public ActionResult Edit(int id, VMAuthor data) { try { if (ModelState.IsValid) { using (Context ctx = new Context()) { ctx.AuthorUpdateJust(id, data); return(RedirectToAction("Index")); } } return(View(data)); } catch (Exception ex) { return(View("Exception", ex)); } }