-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from rajguptaH/develop
Updated KeplerCrud Using
- Loading branch information
Showing
7 changed files
with
25 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 21 additions & 25 deletions
46
WebApiExample/WebApiExample/Utility/Data/Service/StudentService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,49 @@ | ||
using WebApiCrud.Utility.Data.Service.Interface; | ||
using KeplerCrud.Repository; | ||
using System.Data; | ||
using WebApiCrud.Library.Connection.Interface; | ||
using WebApiCrud.Models; | ||
using KeplerCrud.Repository; | ||
using WebApiCrud.Utility.Data.Service.Interface; | ||
|
||
namespace WebApiCrud.Utility.Data.Service | ||
{ | ||
public class StudentService : IStudentService | ||
{ | ||
private readonly IKeplerRepository<StudentModel> _keplerRepository; | ||
public StudentService(IKeplerRepository<StudentModel> keplerRepository) | ||
{ | ||
_keplerRepository = keplerRepository; | ||
private readonly IConnectionBuilder _connectionBuilder; | ||
public StudentService(IConnectionBuilder connectionBuilder) | ||
{ | ||
_connectionBuilder = connectionBuilder; | ||
} | ||
|
||
public bool Delete(int id) | ||
{ | ||
return _keplerRepository.SoftDelete(id); | ||
|
||
} | ||
using IDbConnection con = _connectionBuilder.GetConnection; | ||
return con.SoftDelete<StudentModel>(id); | ||
|
||
} | ||
public List<StudentModel> Get() | ||
{ | ||
return _keplerRepository.GetAll(false); | ||
using IDbConnection con = _connectionBuilder.GetConnection; | ||
var result = con.GetAll<StudentModel>(true); | ||
return result; | ||
} | ||
|
||
public StudentModel Get(int id) | ||
{ | ||
using IDbConnection con = _connectionBuilder.GetConnection; | ||
List<ConditionPair> conditionPairs = new List<ConditionPair> | ||
{ | ||
new ConditionPair() { Value = $"{id}", Where = "Id" } | ||
}; | ||
return _keplerRepository.Get(conditionPairs,true); | ||
return con.Get<StudentModel>(conditionPairs, false); | ||
} | ||
|
||
public int Insert(StudentModel uiPageTypeModel) | ||
{ | ||
var result = _keplerRepository.Insert(uiPageTypeModel); | ||
if (result) | ||
{ | ||
return 1; | ||
} | ||
else | ||
{ | ||
return 0; | ||
} | ||
using IDbConnection con = _connectionBuilder.GetConnection; | ||
var result = con.Insert(uiPageTypeModel); | ||
return result ? 1 : 0; | ||
} | ||
|
||
public bool Update(StudentModel uiPageTypeModel) | ||
{ | ||
return _keplerRepository.Update(uiPageTypeModel); | ||
using IDbConnection con = _connectionBuilder.GetConnection; | ||
return con.Update(uiPageTypeModel); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters