public ActionResult AddBasics(UI.ViewModels.BasicsModel BasicsInfo) { if (ModelState.IsValid) { var UserInfo = (DAL.UserInfo)Session["UserLogin"]; var BasicsResult = DbEntities.BasicsInfo.SingleOrDefault(p => p.UserId == UserInfo.UserID); if (BasicsResult == null) { DAL.BasicsInfo NewBasics = new BasicsInfo(); NewBasics.ID = BLL.BaseUtility.GenerateGUID(); NewBasics.UserId = UserInfo.UserID; NewBasics.CountryId = BasicsInfo.CountryId; NewBasics.Address = BasicsInfo.Address; NewBasics.Address2 = BasicsInfo.Address2; NewBasics.City = BasicsInfo.City; NewBasics.Province = BasicsInfo.Province; NewBasics.PostalCode = BasicsInfo.PostalCode; NewBasics.PhoneNumberId = BasicsInfo.PhoneNumberId; NewBasics.AreaCode = BasicsInfo.AreaCode; NewBasics.PhoneNumber = BasicsInfo.PhoneNumber; NewBasics.Ext = BasicsInfo.Ext; DbEntities.BasicsInfo.AddObject(NewBasics); DbEntities.SaveChanges(); } else { BasicsResult.UserId = UserInfo.UserID; BasicsResult.CountryId = BasicsInfo.CountryId; BasicsResult.Address = BasicsInfo.Address; BasicsResult.Address2 = BasicsInfo.Address2; BasicsResult.City = BasicsInfo.City; BasicsResult.Province = BasicsInfo.Province; BasicsResult.PostalCode = BasicsInfo.PostalCode; BasicsResult.PhoneNumberId = BasicsInfo.PhoneNumberId; BasicsResult.AreaCode = BasicsInfo.AreaCode; BasicsResult.PhoneNumber = BasicsInfo.PhoneNumber; BasicsResult.Ext = BasicsInfo.Ext; DbEntities.SaveChanges(); } return RedirectToAction("AddSkills", "Home"); } ViewBag.CountryList = new SelectList(DbEntities.Country.ToList(), "CountryID", "CountryName", BasicsInfo.CountryId); ViewBag.PhoneNumberList = new SelectList(DbEntities.PhoneNumber.ToList(), "PhoneNumberID", "PhoneNumberName", BasicsInfo.PhoneNumberId); return View(BasicsInfo); }
/// <summary> /// Create a new BasicsInfo object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="userId">Initial value of the UserId property.</param> /// <param name="countryId">Initial value of the CountryId property.</param> /// <param name="address">Initial value of the Address property.</param> public static BasicsInfo CreateBasicsInfo(global::System.String id, global::System.String userId, global::System.Int32 countryId, global::System.String address) { BasicsInfo basicsInfo = new BasicsInfo(); basicsInfo.ID = id; basicsInfo.UserId = userId; basicsInfo.CountryId = countryId; basicsInfo.Address = address; return basicsInfo; }
/// <summary> /// Deprecated Method for adding a new object to the BasicsInfo EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToBasicsInfo(BasicsInfo basicsInfo) { base.AddObject("BasicsInfo", basicsInfo); }