public void Insert(int workID, string newMessage, int memberID) { if (!IsMember(workID, memberID)) { throw new ArgumentOutOfRangeException(); } var script = @"INSERT INTO `spd`.`work_chat` ( `WorkID`,`Message`, `CompleteDate`,`CreatedBy`,`CreatedDate`,`UpdatedBy`,`UpdatedDate` ) VALUES ( @WorkID,@Message, @CreatedBy,NOW(),@UpdatedBy,NOW() ); SELECT LAST_INSERT_ID();"; var newItem = new WorkChat() { CreatedBy = memberID, UpdatedBy = memberID, Message = newMessage, WorkID = workID }; DB.Execute(script, newItem); }
public void CreateMessage(WorkChat msg, int publishedId, int?parentId, string userName) { msg.Owner = Manager <UserManager> .Instance.GetCurrentUser(userName); msg.Work = Ctx.Works.Find(publishedId); if (parentId.HasValue) { msg.Parent = Ctx.WorkChats.Find(parentId.Value); } Ctx.WorkChats.Add(msg); SaveChanges(); }