public ActionResult CategoryEdit(MemberInformationCategory p_info) { //TODO: FormCollection collection==>不要用 try { //todo: //int memberID = 1; //todo: CMember member = Session[CDictionary.welcome] as CMember; int memberID = member.fMemberId; //(int)Session["MemberID"]; SingleApartmentEntities db = new SingleApartmentEntities(); MemberInformationCategory info = db.MemberInformationCategory.FirstOrDefault(p => p.MemberCategoryID == p_info.MemberCategoryID && p.MemberID == memberID); if (info != null) { info.MemberCategoryName = p_info.MemberCategoryName; db.SaveChanges(); } return(RedirectToAction("UserCategoryList")); } catch { //return View(); return(RedirectToAction("UserCategoryList")); } }
// GET public ActionResult CategoryDelete(int member_id, int category_id) { try { SingleApartmentEntities db = new SingleApartmentEntities(); MemberInformationCategory info = db.MemberInformationCategory.FirstOrDefault(p => p.MemberCategoryID == category_id && p.MemberID == member_id); if (info != null) { db.MemberInformationCategory.Remove(info); db.SaveChanges(); } return(RedirectToAction("UserCategoryList")); } catch { return(RedirectToAction("UserCategoryList")); } }
//no use public void CategoryEdit_JS(int category_id, string category_name) //MemberInformationCategory p_info { //TODO: FormCollection collection==>不要用 try { //todo: //int memberID = 1; //todo: CMember member = Session[CDictionary.welcome] as CMember; int memberID = member.fMemberId; //(int)Session["MemberID"]; SingleApartmentEntities db = new SingleApartmentEntities(); MemberInformationCategory info = db.MemberInformationCategory.FirstOrDefault(p => p.MemberCategoryID == category_id && p.MemberID == memberID); if (info != null) { info.MemberCategoryName = category_name; //p_info.MemberCategoryName; db.SaveChanges(); } } catch { //return View(); } }
public ActionResult CategoryCreate(MemberInformationCategory p_info) { try { SingleApartmentEntities db = new SingleApartmentEntities(); //int memberID = 1; //todo: CMember member = Session[CDictionary.welcome] as CMember; int memberID = member.fMemberId; //(int)Session["MemberID"]; p_info.MemberID = memberID; db.MemberInformationCategory.Add(p_info); db.SaveChanges(); return(RedirectToAction("UserCategoryList")); } catch { return(RedirectToAction("UserCategoryList")); } }