public string StatusChange(int Id, int status) { string result = "Internal Server Error"; if (status > 0 && Id > 0) { try { using (var context = new NCContext.NCContext()) { var survey = context.Surveys.Where(x => x.Id == Id).FirstOrDefault(); if (survey != null) { survey.Status = status; context.Entry(survey).State = EntityState.Modified; context.SaveChanges(); var student = context.Students.Where(x => x.Id == survey.StudentId).FirstOrDefault(); var subject = "Event Subscribed"; var body = "Hi, thank you for giving your time and playing the survey as a result you win the cofee card."; SendEmail(student.Email, body, subject); result = "true"; } } } catch (Exception ex) { result = ex.Message; } } return(result); }
public string ChangeStatus(int Id, int status) { string result = "Internal Server Error"; if (status > 0 && Id > 0) { try { using (var context = new NCContext.NCContext()) { var post = context.Posts.Where(x => x.Id == Id).FirstOrDefault(); if (post != null) { post.ApprovalStatus = status; post.Date = DateTime.Now; context.Entry(post).State = EntityState.Modified; context.SaveChanges(); result = "true"; } } } catch (Exception ex) { result = ex.Message; } } return(result); }
public string EditCategory(EventCategory eventCategory) { using (var context = new NCContext.NCContext()) { context.Entry(eventCategory).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return("true"); } }
public string EditPromotion(Promotion promotion) { string result = ""; using (var context = new NCContext.NCContext()) { context.Entry(promotion).State = EntityState.Modified; context.SaveChanges(); result = "true"; } return(result); }
public string EditPost(Post post) { if (post != null) { using (var context = new NCContext.NCContext()) { context.Entry(post).State = EntityState.Modified; context.SaveChanges(); return("true"); } } return("Internal Server Error"); }
public string EditEvent(Event evnt) { if (evnt != null) { using (var context = new NCContext.NCContext()) { context.Entry(evnt).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return("true"); } } else { return("Internal Server Error"); } }