Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using MusicStore.Api.Business.Interface;
- using MusicStore.Data.Repository;
- using MusicStore.Entities;
- using MongoDB.Bson;
- using MusicStore.Data.Interface;
- using Microsoft.Extensions.Options;
- using MusicStore.Data.DBContext;
- using MongoDB.Bson.Serialization;
- using System;
- using Newtonsoft.Json;
- using System.Linq;
- namespace MusicStore.Api.Business.Manager
- {
- /// <summary>
- /// This is custom repository for user collection
- /// </summary>
- public class UserManager : IUserManager
- {
- #region private variables
- IGenericRepository<User> _dbRepository;
- #endregion
- #region constructor
- public UserManager(IDBManager<User> dbManager)
- {
- this._dbRepository = dbManager.Instance;
- }
- #endregion
- #region public methods
- public async Task<IList<User>> GetAll()
- {
- return await this._dbRepository.GetAll();
- }
- public async Task<User> GetById(string id)
- {
- return await this._dbRepository.GetById(id);
- }
- public async Task<User> Insert(User user)
- {
- user._id = Guid.NewGuid();
- await this._dbRepository.InsertAsync(user);
- return user;
- }
- public Task<bool> Update(User user)
- {
- return _dbRepository.UpdateAsync(user);
- }
- public Task<bool> DeleteById(string id)
- {
- return this._dbRepository.DeleteById(id);
- }
- /// <summary>
- /// Searches for a list of entities that match a key-value pair
- /// </summary>
- /// <param name="key">Property name</param>
- /// <param name="value">Property value</param>
- /// <returns></returns>
- public async Task<IList<User>> SearchFor(string key, string value)
- {
- return await this._dbRepository.SearchFor(key, value);
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement