public ActionResult UpdateProfile(FormCollection form) { PhotoGrapherBasicProfile basic = new PhotoGrapherBasicProfile(); basic.Fk_PhotoGrapher_ID = Int32.Parse(form["PhotoGrapherID"]); basic.Education = form["Education"]; basic.Address = form["PresentLocation"]; basic.Phone = form["Phone"]; basic.Notes = form["Notes"]; ph.Update_Profile_Item(basic); TempData["msg"] = "<script>alert('Update Profile Successfully');</script>"; return(RedirectToAction("Profile", "PhotoGrapher")); }
public bool Add_basicProfile(int id) { var user = Db.PhotoGrapherBasicProfiles.Where(x => x.Fk_PhotoGrapher_ID == id).FirstOrDefault(); if (user == null) { PhotoGrapherBasicProfile p = new PhotoGrapherBasicProfile(); p.Fk_PhotoGrapher_ID = id; p.Address = ""; p.Education = ""; p.Phone = ""; Db.PhotoGrapherBasicProfiles.Add(p); Db.SaveChanges(); return(true); } else { return(false); } }
//Update By default All Field Null public bool Update_Profile_Item(PhotoGrapherBasicProfile BasicAdd) { var user = Db.PhotoGrapherBasicProfiles.Where(x => x.Fk_PhotoGrapher_ID == BasicAdd.Fk_PhotoGrapher_ID).FirstOrDefault(); if (user != null) { user.Fk_PhotoGrapher_ID = BasicAdd.Fk_PhotoGrapher_ID; user.Education = BasicAdd.Education; user.Address = BasicAdd.Address; user.Phone = BasicAdd.Phone; user.Notes = BasicAdd.Notes; Db.SaveChanges(); return(true); } else { return(false); } // Db.Entry(BasicAdd).State = EntityState.Modified; }