public ActionResult AddAbout(AboutSelf AboutSelf, FormCollection form) { AboutSelf.Sex = form["gender"]; AboutSelf.Hobbies = form["hobbies"]; AboutSelf.UserId = Convert.ToInt32(form["UserId"]); if (ModelState.IsValid) { repository.AddAbout(AboutSelf); return View(); } else { PrepareView(); return View("Index", result); } }
public void AddAbout(AboutSelf about) { if (!AboutExist(about.UserId)) //dosen't exist { db.AboutSelf.Add(about); db.SaveChanges(); } }
public AboutSelfFormViewModel(MyBlogRepository repository) { AboutSelf = new AboutSelf(); genderText = new List<String> { "мужской", "женский" }; hobbyText = new List<String> { "спорт", "видеоигры", "коллекционирование", "йога" }; }