Skip to content

Commit

Permalink
Merge pull request #71 from Khurshid0109/dev
Browse files Browse the repository at this point in the history
This keyword replaced with underscore and responce model removed from…
  • Loading branch information
dotnetgoo authored Oct 25, 2023
2 parents 7c3b06c + 4225ff3 commit 89993cd
Show file tree
Hide file tree
Showing 20 changed files with 219 additions and 436 deletions.
16 changes: 8 additions & 8 deletions src/Shamsheer.Data/Repositories/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public class Repository<TEntity> : IRepository<TEntity> where TEntity : Auditabl

public Repository(ShamsheerDbContext dbContext)
{
this._dbContext = dbContext;
this._dbSet = _dbContext.Set<TEntity>();
_dbContext = dbContext;
_dbSet = _dbContext.Set<TEntity>();
}


public async Task<TEntity> InsertAsync(TEntity entity)
{
var entry = await this._dbSet.AddAsync(entity);
var entry = await _dbSet.AddAsync(entity);

await _dbContext.SaveChangesAsync();

Expand All @@ -31,23 +31,23 @@ public async Task<TEntity> InsertAsync(TEntity entity)

public async Task<bool> DeleteAsync(long id)
{
var entity = await this._dbSet.FirstOrDefaultAsync(e => e.Id == id);
var entity = await _dbSet.FirstOrDefaultAsync(e => e.Id == id);
_dbSet.Remove(entity);

return await _dbContext.SaveChangesAsync() > 0;
}


public IQueryable<TEntity> SelectAll()
=> this._dbSet;
=> _dbSet;

public async Task<TEntity> SelectByIdAsync(long id)
=> await this._dbSet.FirstOrDefaultAsync(e => e.Id == id);
=> await _dbSet.FirstOrDefaultAsync(e => e.Id == id);

public async Task<TEntity> UpdateAsync(TEntity entity)
{
var entry = this._dbContext.Update(entity);
await this._dbContext.SaveChangesAsync();
var entry = _dbContext.Update(entity);
await _dbContext.SaveChangesAsync();

return entry.Entity;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,62 +1,35 @@
using Microsoft.AspNetCore.Mvc;
using Shamsheer.Domain.Enums.Chats;
using Shamsheer.Messenger.Api.Helpers;
using Shamsheer.Service.Interfaces.Authorizations;
using Shamsheer.Service.Interfaces.Authorizations.Channels;

namespace Shamsheer.Messenger.Api.Controllers.Authorizations.Channels;

public class ChannelPermissionsController : BaseController
{
private readonly IChannelPermissionService channelPermissionService;
private readonly IChannelPermissionService _channelPermissionService;

public ChannelPermissionsController(IChannelPermissionService channelPermissionService)
{
this.channelPermissionService = channelPermissionService;
_channelPermissionService = channelPermissionService;
}

[HttpPost]
public async Task<IActionResult> PostAsync([FromBody] ChannelPermissionType type)
=> Ok(new Response()
{
Code = 200,
Message = "Success",
Data = await this.channelPermissionService.CreateAsync(type)
});
=> Ok(await _channelPermissionService.CreateAsync(type));

[HttpGet()]
public async Task<IActionResult> GetAllAsync()
=> Ok(new Response()
{
Code = 200,
Message = "Success",
Data = await this.channelPermissionService.RetrieveAllAsync()
});
=> Ok(await _channelPermissionService.RetrieveAllAsync());

[HttpGet("{id}")]
public async Task<IActionResult> GetAsync([FromRoute(Name = "id")] long id)
=> Ok(new Response()
{
Code = 200,
Message = "Success",
Data = await this.channelPermissionService.RetrieveByIdAsync(id)
});
=> Ok(await _channelPermissionService.RetrieveByIdAsync(id));

[HttpPut("{id}")]
public async Task<IActionResult> PutAsync([FromRoute(Name = "id")] long id, [FromBody] ChannelPermissionType type)
=> Ok(new Response()
{
Code = 200,
Message = "Success",
Data = await this.channelPermissionService.ModifyAsync(id, type)
});
=> Ok(await _channelPermissionService.ModifyAsync(id, type));

[HttpDelete("{id}")]
public async Task<IActionResult> DeleteAsync([FromRoute(Name = "id")] long id)
=> Ok(new Response()
{
Code = 200,
Message = "Success",
Data = await this.channelPermissionService.RemoveAsync(id)
});
=> Ok(await _channelPermissionService.RemoveAsync(id));
}
Original file line number Diff line number Diff line change
@@ -1,63 +1,36 @@
using Microsoft.AspNetCore.Mvc;
using Shamsheer.Domain.Enums.Chats;
using Shamsheer.Messenger.Api.Helpers;
using Shamsheer.Service.Interfaces.Authorizations;
using Shamsheer.Service.Interfaces.Authorizations.Channels;

namespace Shamsheer.Messenger.Api.Controllers.Authorizations.Channels
{
public class ChannelRolesController : BaseController
{
private readonly IChannelRoleService channelRoleService;
private readonly IChannelRoleService _channelRoleService;

public ChannelRolesController(IChannelRoleService channelRoleService)
{
this.channelRoleService = channelRoleService;
_channelRoleService = channelRoleService;
}

[HttpPost]
public async Task<IActionResult> PostAsync([FromBody] ChatRole chatRole)
=> Ok(new Response()
{
Code = 200,
Message = "Success",
Data = await this.channelRoleService.CreateAsync(chatRole)
});
=> Ok(await _channelRoleService.CreateAsync(chatRole));

[HttpGet()]
public async Task<IActionResult> GetAllAsync()
=> Ok(new Response()
{
Code = 200,
Message = "Success",
Data = await this.channelRoleService.RetrieveAllAsync()
});
=> Ok(await _channelRoleService.RetrieveAllAsync());

[HttpGet("{id}")]
public async Task<IActionResult> GetAsync([FromRoute(Name = "id")] long id)
=> Ok(new Response()
{
Code = 200,
Message = "Success",
Data = await this.channelRoleService.RetrieveByIdAsync(id)
});
=> Ok(await _channelRoleService.RetrieveByIdAsync(id));

[HttpPut("{id}")]
public async Task<IActionResult> PutAsync([FromRoute(Name = "id")] long id, [FromBody] ChatRole chatRole)
=> Ok(new Response()
{
Code = 200,
Message = "Success",
Data = await this.channelRoleService.ModifyAsync(id, chatRole)
});
=> Ok(await _channelRoleService.ModifyAsync(id, chatRole));

[HttpDelete("{id}")]
public async Task<IActionResult> DeleteAsync([FromRoute(Name = "id")] long id)
=> Ok(new Response()
{
Code = 200,
Message = "Success",
Data = await this.channelRoleService.RemoveAsync(id)
});
=> Ok(await _channelRoleService.RemoveAsync(id));
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.AspNetCore.Mvc;
using Shamsheer.Domain.Enums.Chats;
using Shamsheer.Service.Interfaces.Authorizations;

namespace Shamsheer.Messenger.Api.Controllers.Authorizations.Groups;

public class GroupPermissionsController : BaseController
{

private readonly IGroupPermissionService _groupPermissionService;

public GroupPermissionsController(IGroupPermissionService groupPermissionService)
{
_groupPermissionService = groupPermissionService;
}

[HttpPost]
public async Task<IActionResult> PostAsync([FromBody] GroupPermissionType type)
=> Ok(await _groupPermissionService.CreateAsync(type));

[HttpGet()]
public async Task<IActionResult> GetAllAsync()
=> Ok(await _groupPermissionService.RetrieveAllAsync());

[HttpGet("{id}")]
public async Task<IActionResult> GetAsync([FromRoute(Name = "id")] long id)
=> Ok(await _groupPermissionService.RetrieveByIdAsync(id));

[HttpPut("{id}")]
public async Task<IActionResult> PutAsync([FromRoute(Name = "id")] long id, [FromBody] GroupPermissionType type)
=> Ok(await _groupPermissionService.ModifyAsync(id, type));

[HttpDelete("{id}")]
public async Task<IActionResult> DeleteAsync([FromRoute(Name = "id")] long id)
=> Ok(await _groupPermissionService.RemoveAsync(id));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Microsoft.AspNetCore.Mvc;
using Shamsheer.Domain.Enums.Chats;
using Shamsheer.Service.Interfaces.Authorizations;

namespace Shamsheer.Messenger.Api.Controllers.Authorizations.Groups;

public class GroupRolesController : BaseController
{
private readonly IGroupRoleService _groupRoleService;

public GroupRolesController(IGroupRoleService groupRoleService)
{
_groupRoleService = groupRoleService;
}

[HttpPost]
public async Task<IActionResult> PostAsync([FromBody] ChatRole chatRole)
=> Ok(await _groupRoleService.CreateAsync(chatRole));

[HttpGet()]
public async Task<IActionResult> GetAllAsync()
=> Ok(await _groupRoleService.RetrieveAllAsync());

[HttpGet("{id}")]
public async Task<IActionResult> GetAsync([FromRoute(Name = "id")] long id)
=> Ok(await _groupRoleService.RetrieveByIdAsync(id));

[HttpPut("{id}")]
public async Task<IActionResult> PutAsync([FromRoute(Name = "id")] long id, [FromBody] ChatRole chatRole)
=> Ok(await _groupRoleService.ModifyAsync(id, chatRole));

[HttpDelete("{id}")]
public async Task<IActionResult> DeleteAsync([FromRoute(Name = "id")] long id)
=> Ok(await _groupRoleService.RemoveAsync(id));
}
Loading

0 comments on commit 89993cd

Please sign in to comment.