public Event CreateEvent(string title, string text, string specificity) { Event ev = new Event { Title = title, Text = text, Specificity = specificity, StateId = 1, Created = System.DateTime.Now }; _datacontext.Events.InsertOnSubmit(ev); _datacontext.SubmitChanges(); return(ev); }
public Category CreateCategory(string name, string text) { Category c = new Category { CategoryName = name, Text = text }; _datacontext.Categories.InsertOnSubmit(c); _datacontext.SubmitChanges(); return(c); }
public Lab CreateLab(string title, string text) { Lab l = new Lab(); l.Title = title; l.Text = text; l.CreatedOn = DateTime.Now; _datacontext.Labs.InsertOnSubmit(l); _datacontext.SubmitChanges(); return(l); }
public Task CreateTask(string title, string text) { MembershipUser user = Membership.GetUser(HttpContext.Current.User.Identity.Name); // user add task himself string userId = user.ToString(); Guid userGuid = new Guid(user.ProviderUserKey.ToString()); Task t = new Task { Title = title, Text = text, AssignedOn = userGuid, CreatedOn = System.DateTime.Now, StateId = 1 }; _datacontext.Tasks.InsertOnSubmit(t); _datacontext.SubmitChanges(); return(t); }
public Test CreateTest() { MembershipUser user = Membership.GetUser(HttpContext.Current.User.Identity.Name); // start test for current user string userId = user.ToString(); Guid userGuid = new Guid(user.ProviderUserKey.ToString()); Test newTest = new Test { UserId = userGuid, UserName = HttpContext.Current.User.Identity.Name, AnswersAll = 0, AnswersCorrectly = 0, CategoryName = "Об'єктно-орієнтоване програмування", Began = System.DateTime.Now }; _datacontext.Tests.InsertOnSubmit(newTest); _datacontext.SubmitChanges(); return(newTest); }
public Theme CreateTheme(int categoryId, string themeName) { MembershipUser user = Membership.GetUser(HttpContext.Current.User.Identity.Name); // creating "Theme" by user in current "Category" string userId = user.ToString(); Guid userGuid = new Guid(user.ProviderUserKey.ToString()); Theme t = new Theme { ThemeName = themeName, CategoryId = categoryId, AssignedOn = userGuid, CreatedOn = System.DateTime.Now }; _datacontext.Themes.InsertOnSubmit(t); _datacontext.SubmitChanges(); return(t); }
public Message CreateMessage(string answerTo, string text) { MembershipUser user = Membership.GetUser(HttpContext.Current.User.Identity.Name); string userId = user.ToString(); Guid userGuid = new Guid(user.ProviderUserKey.ToString()); string catName = InputMessageContext.Current.CurrentMessage.CategoryName; int thId = int.Parse(InputMessageContext.Current.CurrentMessage.ThemeId.ToString()); Message m = new Message { AnswerTo = answerTo, UserId = userGuid, CategoryName = catName, Text = text, DateTime = System.DateTime.Now, ThemeId = thId }; _datacontext.Messages.InsertOnSubmit(m); _datacontext.SubmitChanges(); return(m); }
public Student CreateStudent(Student s) { MembershipUser user = Membership.GetUser(HttpContext.Current.User.Identity.Name); string userId = user.ToString(); Guid userGuid = new Guid(user.ProviderUserKey.ToString()); s.UserId = userGuid; s.Created = System.DateTime.Now; _datacontext.Students.InsertOnSubmit(s); _datacontext.SubmitChanges(); LabResult lr = new LabResult(); lr.StudentId = s.StudentId; lr.Lab1 = "-"; lr.Lab2 = "-"; lr.Lab3 = "-"; _datacontext.LabResults.InsertOnSubmit(lr); _datacontext.SubmitChanges(); return(s); }
public void CreateQuestion(Question q) { _datacontext.Questions.InsertOnSubmit(q); // add new question to database (only "admin") _datacontext.SubmitChanges(); }