/// <summary> /// delete a record /// </summary> /// <param name="id"></param> /// <returns></returns> public static Msg Delete(Guid id) { var msg = new Msg(); try { var goOn = TopicElected.Exists(id); if (!goOn) { msg.Error = true; msg.Body = string.Format("Topic {0} doesn't exist!", id); } else { var dbm = ListAll().Single(x => x.Id.Equals(id)); using (var db = new GarfielderEntities()) { db.Attach(dbm); db.DeleteObject(dbm); db.SaveChanges(); ClearCache(); }//using } } catch (Exception ex) { msg.Error = true; msg.Body = ex.Message; } return(msg); }
/// <summary> /// star a topic /// </summary> /// <param name="id"></param> /// <param name="who"></param> /// <param name="noStar"></param> /// <returns></returns> public static Msg Star(Guid id, string who, bool noStar = false) { var msg = new Msg(); try { if (TopicElected.Exists(id)) { return(msg); } msg = TopicElected.Create(id, DateTime.Now, DateTime.Now.AddMonths(1), who); } catch (Exception ex) { msg.Error = true; msg.Body = ex.Message; } return(msg); }