public ActionResult LinkEdit(int id = 0) { LinkEditModel linkModel; if (id == 0) { linkModel = new LinkEditModel(); } else { var link = friendLinkLogic.GetFriendLink(id); linkModel = new LinkEditModel() { ID = link.ID, KeyWords = link.Remark, LinkMan = link.LinkMan, LinkUrl = link.LinkUrl, SiteName = link.Name }; } return View(linkModel); }
public ActionResult LinkEdit(LinkEditModel linkModel) { if(!ModelState.IsValid) { return View(); } T_FriendLink link; bool result = false; if (linkModel.ID == 0) { link = new T_FriendLink() { AddDate = DateTime.Now, AddUserID = user.UserId, LinkMan = linkModel.LinkMan, LinkUrl = linkModel.LinkUrl, Name = linkModel.SiteName, State = 1, Remark = linkModel.KeyWords }; result = friendLinkLogic.AddFriendLink(link); return RedirectToAction("Links"); } else { link = friendLinkLogic.GetFriendLink(linkModel.ID); link.Name = linkModel.SiteName; link.LinkUrl = linkModel.LinkUrl; link.Remark = linkModel.KeyWords; link.LinkMan = linkModel.LinkMan; result=friendLinkLogic.UpdateFriendLink(link); } if(result) { WebCache.Remove(friendLinkLogic.FriendLinksKey); return RedirectToAction("links"); } return View(); }