Skip to content

Commit

Permalink
re modeling.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre authored and Alexandre committed Apr 4, 2020
1 parent 3896d28 commit 59b8e2d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 74 deletions.
28 changes: 2 additions & 26 deletions AES.UpGram.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using UpSocial.UpGram.Core;
using UpSocial.UpGram.Core;
using UpSocial.UpGram.Domain.Entity;
using UpSocial.UpGram.Service;

Expand All @@ -13,29 +12,6 @@ static void Main(string[] args)

var service = new BaseService<AccountEntity>();
var account = service.Get(1);
var accounts = service.Get();

//var add = service.Post(new AccountEntity()
//{
// Name = "carolinaseneda",
// Password = "28vegana",
// IsActive = true,
// CreatedOn = DateTime.UtcNow
//});

//var delete = service.Delete(3);

//var update = service.Put(new AccountEntity()
//{
// Id = 2,
// Name = "carolinaseneda",
// Password = "28vegana",
// IsActive = true,
// CreatedOn = DateTime.UtcNow
//});




var connector = new Connector(new AccountEntity()
{
Expand All @@ -49,7 +25,7 @@ static void Main(string[] args)

if (login)
{



//string fromNextId = "QVFBZ0RGZVZFRm9vclBvcTJOWHRaOEQtUUp2bDBfYkdtWkZXVmktSEVlNDdzSWJBYzRjNGYybnRRaTZqeGdHZm1mZUU3SWhKT3lmZTUzUXFEM0dFSG9GMQ=="; // alana_rox
Expand Down
4 changes: 2 additions & 2 deletions AES.UpGram.Core/Connector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public Connector(AccountEntity account)
_apiConnector = InstaApiBuilder.CreateBuilder()
.UseLogger(new DebugLogger(_logLevel))
.SetRequestDelay(RequestDelay.FromSeconds(_requestDelayFromSec, _requestDelayFromSec))
.SetSessionHandler(new FileSessionHandler()
{
.SetSessionHandler(new FileSessionHandler()
{
FilePath = $"{account.Name.ToLower()}.bin"
})
.SetUser(new UserSessionData()
Expand Down
10 changes: 5 additions & 5 deletions AES.UpGram.Core/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ public async Task<string> Follow(string userName, string fromNextId = null)
if (result.Succeeded)
{
var users = result.Value;

foreach (var user in users)
{
if ((await _apiUserProcessor.FollowUserAsync(user.Pk)).Succeeded)
{
{

}
else
{

}
}

return users?.NextMaxId ?? string.Empty;
}

Expand All @@ -65,7 +65,7 @@ public async Task<InstaUserShortList> UnFollow()
{
if ((await _apiUserProcessor.UnFollowUserAsync(user.Pk)).Succeeded)
{

}
else
{
Expand Down
4 changes: 1 addition & 3 deletions AES.UpGram.Model/Entity/BaseEntity.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace UpSocial.UpGram.Domain.Entity
namespace UpSocial.UpGram.Domain.Entity
{
public abstract class BaseEntity
{
Expand Down
76 changes: 38 additions & 38 deletions AES.UpGram.Repository/Repository/BaseDapperRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,58 @@

namespace UpSocial.UpGram.Infra.Data.Repository
{
public class BaseDapperRepository<T> : SqlRepository, IRepository<T> where T : BaseEntity
{
#region Changing
public class BaseDapperRepository<T> : SqlRepository, IRepository<T> where T : BaseEntity
{
#region Changing

public long Insert(T entity)
{
using var conn = Connect();
public long Insert(T entity)
{
using var conn = Connect();

return conn.Insert(entity);
}
return conn.Insert(entity);
}

public bool Update(T entity)
{
using var conn = Connect();
public bool Update(T entity)
{
using var conn = Connect();

return conn.Update(entity);
}
return conn.Update(entity);
}

public bool Remove(int id)
{
using var conn = Connect();
public bool Remove(int id)
{
using var conn = Connect();

var entity = conn.Get<T>(id);
var entity = conn.Get<T>(id);

return conn.Delete(entity);
}
return conn.Delete(entity);
}

public bool Remove()
{
using var conn = Connect();
public bool Remove()
{
using var conn = Connect();

return conn.DeleteAll<T>();
}
return conn.DeleteAll<T>();
}

#endregion
#endregion

#region Reading
#region Reading

public T Select(int id)
{
using var conn = Connect();
public T Select(int id)
{
using var conn = Connect();

return conn.Get<T>(id);
}
return conn.Get<T>(id);
}

public IEnumerable<T> SelectAll()
{
using var conn = Connect();
public IEnumerable<T> SelectAll()
{
using var conn = Connect();

return conn.GetAll<T>();
}
return conn.GetAll<T>();
}

#endregion
}
#endregion
}
}

0 comments on commit 59b8e2d

Please sign in to comment.