public ActionResult AjaxAddFavourite(FormCollection Fm) { int postId = Globals.SafeInt(Fm["TargetId"], 0); if (Fm["Type"] == "Video") { Maticsoft.BLL.SNS.Posts posts = new Maticsoft.BLL.SNS.Posts(); if (posts.UpdateFavCount(postId)) { return base.Content("Ok"); } return base.Content("No"); } Maticsoft.Model.SNS.UserFavourite favModel = new Maticsoft.Model.SNS.UserFavourite(); Maticsoft.BLL.SNS.UserFavourite favourite2 = new Maticsoft.BLL.SNS.UserFavourite(); int topicId = Globals.SafeInt(Fm["TopicId"], 0); int replyId = Globals.SafeInt(Fm["ReplyId"], 0); favModel.Type = (Fm["Type"] == "Product") ? 1 : 0; favModel.TargetID = Globals.SafeInt(Fm["TargetId"], 0); favModel.CreatedDate = DateTime.Now; favModel.CreatedUserID = base.currentUser.UserID; favModel.CreatedNickName = base.currentUser.NickName; if (favourite2.Exists(base.currentUser.UserID, favModel.Type, favModel.TargetID)) { return base.Content("Repeat"); } if (favourite2.AddEx(favModel, topicId, replyId)) { return base.Content("Ok"); } return base.Content("No"); }
public Maticsoft.Model.SNS.UserFavourite DataRowToModel(DataRow row) { Maticsoft.Model.SNS.UserFavourite favourite = new Maticsoft.Model.SNS.UserFavourite(); if (row != null) { if ((row["FavouriteID"] != null) && (row["FavouriteID"].ToString() != "")) { favourite.FavouriteID = int.Parse(row["FavouriteID"].ToString()); } if ((row["TargetID"] != null) && (row["TargetID"].ToString() != "")) { favourite.TargetID = int.Parse(row["TargetID"].ToString()); } if ((row["Type"] != null) && (row["Type"].ToString() != "")) { favourite.Type = int.Parse(row["Type"].ToString()); } if ((row["CreatedUserID"] != null) && (row["CreatedUserID"].ToString() != "")) { favourite.CreatedUserID = int.Parse(row["CreatedUserID"].ToString()); } if (row["CreatedNickName"] != null) { favourite.CreatedNickName = row["CreatedNickName"].ToString(); } if ((row["OwnerUserID"] != null) && (row["OwnerUserID"].ToString() != "")) { favourite.OwnerUserID = new int?(int.Parse(row["OwnerUserID"].ToString())); } if (row["OwnerNickName"] != null) { favourite.OwnerNickName = row["OwnerNickName"].ToString(); } if (row["Description"] != null) { favourite.Description = row["Description"].ToString(); } if (row["Tags"] != null) { favourite.Tags = row["Tags"].ToString(); } if ((row["CreatedDate"] != null) && (row["CreatedDate"].ToString() != "")) { favourite.CreatedDate = DateTime.Parse(row["CreatedDate"].ToString()); } } return favourite; }