1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using Microsoft.EntityFrameworkCore;
- using RestSharp;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Cryptography;
- using System.Text;
- using UnivateProperties_API.Context;
- using UnivateProperties_API.Model.Financial;
-
- namespace UnivateProperties_API.Repository.Financial
- {
- public class PaymentRepository : IRepository<Payment>
- {
- private readonly DataContext _dbContext;
-
- public PaymentRepository(DataContext dbContext)
- {
- _dbContext = dbContext;
- }
-
- public List<Payment> Get(Func<Payment, bool> where)
- {
- return _dbContext.Payments.Where(where).ToList();
- }
-
- public List<Payment> GetAll()
- {
- return _dbContext.Payments.OrderByDescending(p => p.Created).ToList();
- }
-
- public Payment GetDetailed(Func<Payment, bool> first)
- {
- var item = _dbContext.Payments.FirstOrDefault(first);
- return item;
- }
-
- public List<Payment> GetDetailedAll()
- {
- return GetAll();
- }
-
- public void Insert(Payment item)
- {
- _dbContext.Add(item);
- Save();
- }
-
- public void Insert(IEnumerable<Payment> items)
- {
- foreach(var item in items)
- {
- _dbContext.Add(item);
- }
- Save();
- }
-
- public int NewId()
- {
- throw new NotImplementedException();
- }
-
- public void Remove(Payment item)
- {
- var i = _dbContext.Payments.Find(item);
- _dbContext.Payments.Remove(i);
- Save();
- }
-
- public void Remove(IEnumerable<Payment> items)
- {
- foreach (var item in items)
- {
- var i = _dbContext.Payments.Find(item);
- _dbContext.Payments.Remove(i);
- }
- Save();
- }
-
- public void RemoveAtId(int item)
- {
- var i = _dbContext.Payments.Find(item);
- _dbContext.Payments.Remove(i);
- Save();
- }
-
- public void Save()
- {
- _dbContext.SaveChanges();
- }
-
- public void Update(Payment item)
- {
- _dbContext.Entry(item).State = EntityState.Modified;
- Save();
- }
- }
- }
|