public ActionResult SaveWork(Profile_Work profile_work) { userId = User.Identity.Name; profile_work.UserId = userId; if (ModelState.IsValid) { if (profile_work.ProfileWorkId == Guid.Empty) { profile_work.ProfileWorkId = Guid.NewGuid(); //db.Profile_Work.AddObject(profile_work); db.Profile_Work.Add(profile_work); db.SaveChanges(); //Mapping Guid objectId = db.Profile_Basic.Where(x => x.UserId == profile_work.UserId).SingleOrDefault().ProfileBasicId; TagAttributeMappingManager mapping = new TagAttributeMappingManager(); mapping.AddRootAttribute(objectId, profile_work.UserId, "JobSeekerProfile"); mapping.AddSecondLevelAttribute(objectId, "Work Experience", "JobSeekerProfile"); mapping.AddThirdLevelAttribute(profile_work, objectId, "JobSeekerProfile", "Profile.Work"); } else { db.Profile_Work.Attach(profile_work); //db.ObjectStateManager.ChangeObjectState(profile_work, EntityState.Modified); db.Entry(profile_work).State = EntityState.Modified; db.SaveChanges(); //Mapping Guid objectId = db.Profile_Basic.Where(x=>x.UserId == profile_work.UserId).SingleOrDefault().ProfileBasicId; TagAttributeMappingManager mapping = new TagAttributeMappingManager(); mapping.AddRootAttribute(objectId, profile_work.UserId, "JobSeekerProfile"); mapping.AddSecondLevelAttribute(objectId, "Work Experience", "JobSeekerProfile"); mapping.AddThirdLevelAttribute(profile_work, objectId, "JobSeekerProfile", "Profile.Work"); } } var listProfileWork = db.Profile_Work.Where(x => x.UserId == userId); return PartialView("ListProfileWorkView", listProfileWork); }
public ActionResult CreateWork() { Profile_Work profile_work = new Profile_Work(); return PartialView("EditProfileWorkView", profile_work); }