public string Get(string password, string email) { User user = new User(email, password); if (user.SessionID == null) { return(ObjectToJsonConverter.ObjectToJson(new Error(ErrorCodes.USER_NOT_IN_DB))); } return(ObjectToJsonConverter.ObjectToJson(user.SessionID)); }
public string Get(string email) { SqlCommand UserInfo = new SqlCommand(UserQueries.UserInfo); UserInfo.Parameters.AddWithValue("@email", email); DataSet userData = new DataSet(); userData = DBManager.ExecuteCommand(UserInfo); return(ObjectToJsonConverter.ObjectToJson(new User(userData.Tables[0].Rows[0]))); }
public void Convert() { CSVToObjectConverter CSVToObjectConverter = new CSVToObjectConverter(); CSVToObjectConverter.Convert(); var basicJsonStructureList = CSVToObjectConverter.BasicJsonStructureList; var complexJsonStructureList = CSVToObjectConverter.ComplexJsonStructureList; ObjectToJsonConverter ObjectToJsonConverter = new ObjectToJsonConverter(basicJsonStructureList, complexJsonStructureList); ObjectToJsonConverter.Convert(); }
public void ConvertToSrce() { var c = new ObjectToJsonConverter <Person>(); var s = c.ConvertToSrce(null); Assert.IsNull(s); s = c.ConvertToSrce("{\"FirstName\":\"Jen\",\"LastName\":\"Browne\"}"); Assert.IsNotNull(s); Assert.AreEqual("Jen", s.FirstName); Assert.AreEqual("Browne", s.LastName); }
public void ConvertToDest() { var c = new ObjectToJsonConverter <Person>(); var d = c.ConvertToDest(null); Assert.IsNull(d); d = c.ConvertToDest(new Person { FirstName = "Jen", LastName = "Browne" }); Assert.AreEqual("{\"FirstName\":\"Jen\",\"LastName\":\"Browne\"}", d); }
public string Get(int userId) { SqlCommand UserPosts = new SqlCommand(PostQueries.UserPosts); UserPosts.Parameters.AddWithValue("@id", userId); DataSet postData = new DataSet(); postData = DBManager.ExecuteCommand(UserPosts); Post post = new Post(postData.Tables[0].Rows[0]); return(ObjectToJsonConverter.ObjectToJson(post)); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { var recipientsJsonConverter = new ObjectToJsonConverter <List <Recipient> >(); modelBuilder.Entity <Profile>() .HasKey(p => p.EmailAddress); modelBuilder.Entity <MailFolder>() .HasKey(f => f.Id); modelBuilder.Entity <Message>(entity => { entity.HasKey(m => m.Id); entity.Property(m => m.ReceivedDateTime) .HasConversion(new DateTimeOffsetToBytesConverter()); entity.Property(m => m.Sender) .HasConversion(new ObjectToJsonConverter <Recipient>()); entity.Property(m => m.ToRecipients) .HasConversion(recipientsJsonConverter); entity.Property(m => m.CcRecipients) .HasConversion(recipientsJsonConverter); entity.HasIndex(m => m.ReceivedDateTime); entity.HasIndex(m => m.FolderId); }); modelBuilder.Entity <MessageSummary>(entity => { entity.HasNoKey(); entity.Property(m => m.ReceivedDateTime) .HasConversion(new DateTimeOffsetToBytesConverter()); entity.Property(m => m.Sender) .HasConversion(new ObjectToJsonConverter <Recipient>()); entity.Property(m => m.ToRecipients) .HasConversion(recipientsJsonConverter); entity.Property(m => m.CcRecipients) .HasConversion(recipientsJsonConverter); entity.ToQuery(() => Messages.Select(m => new MessageSummary() { Id = m.Id, BodyPreview = m.BodyPreview, CcRecipients = m.CcRecipients, FolderId = m.FolderId, HasAttachments = m.HasAttachments, Importance = m.Importance, IsDraft = m.IsDraft, IsFlagged = m.IsFlagged, IsRead = m.IsRead, ReceivedDateTime = m.ReceivedDateTime, Sender = m.Sender, Subject = m.Subject, ThreadId = m.ThreadId, ThreadPosition = m.ThreadPosition, ToRecipients = m.ToRecipients })); }); modelBuilder.Entity <MessageDetail>(entity => { entity.HasNoKey(); entity.ToQuery(() => Messages.Select(m => new MessageDetail() { Id = m.Id, Body = m.Body, BodyType = m.BodyType })); }); }