public void AddDummyUser() { if (!context.Users.Any(u => u.Id.Equals(Guid.Parse("6A1BA20A-8D25-4E71-8BD8-E6872FD53ADA")))) { context.Users.Add(new User { FirstName = "John", LastName = "Doe", Email = "*****@*****.**", Id = Guid.Parse("6A1BA20A-8D25-4E71-8BD8-E6872FD53ADA") }); context.SaveChanges(); } }
public Project CreateProject(string name) { var project = new Project() { Name = name, ExpiryDate = DateTime.Now.AddYears(2), IssueDate = DateTime.Now }; context.Projects.Add(project); context.SaveChanges(); return(project); }
/// <summary> /// Inserts an IAnnotation into the Database. /// </summary> /// <param name="annotation"></param> public void InsertAnnotation(IAnnotation annotation) { Annotation newItem = new Annotation() { ChallengeID = annotation.ChallengeID, AnswerText = annotation.Answer, UserID = annotation.UserID, Latitude = annotation.Latitude, Longitude = annotation.Longitude, LocalTime = annotation.LocalTime }; context.Annotations.Add(newItem); context.SaveChanges(); }
public ChallengeType CreateChallengeType(string name, string description, IEnumerable <string> answers) { var challengeType = new ChallengeType() { Answers = answers.Select(i => new Answer() { Text = i }).ToList(), Name = name, Description = description }; context.ChallengeTypes.Add(challengeType); context.SaveChanges(); return(challengeType); }
private bool MigrateChallege(Guid projectId, Guid challengeTypeId, string fileName) { try { context.Challenges.Add(new data.Models.Challenge() { Annotations = null, ChallengeTypeID = challengeTypeId, FileName = fileName, ID = new Guid(), ProjectID = projectId }); context.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }