Esempio n. 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="crudService">The persistence service that will actually create, read and update data.</param>
 /// <param name="options"></param>
 public CrudPersistenceHelper(ICrudable <TModelCreate, TModel, TId> crudService, CrudPersistenceHelperOptions options)
 {
     _readService = crudService as IRead <TModel, TId>;
     InternalContract.Require(_readService != null, $"Parameter {nameof(crudService)} must implement {nameof(IRead<TModel, TId>)}.");
     _crudService = crudService;
     _options     = options;
 }
        //  private readonly YearsRepository yearsRepository;

        public LoanRepaymentsController()
        {
            loanRepaymentRepo = new LoanRepaymentRepository();
            creditsRepsitory  = new Creditsrepository();
            monthRepository   = new MonthRepository();
            //  yearsRepository = new YearsRepository();
        }
Esempio n. 3
0
 /// <summary>
 /// Constructor for TOneModel that implements <see cref="IUniquelyIdentifiable{TId}"/>.
 /// </summary>
 /// <param name="service"></param>
 /// <param name="cache"></param>
 /// <param name="flushCacheDelegateAsync"></param>
 /// <param name="options"></param>
 public SlaveToMasterAutoCache(ICrudable service,
                               IDistributedCache cache, FlushCacheDelegateAsync flushCacheDelegateAsync = null,
                               AutoCacheOptions options = null)
     : this(service, item => ((IUniquelyIdentifiable <SlaveToMasterId <TId> >)item).Id, cache,
            flushCacheDelegateAsync, options)
 {
 }
Esempio n. 4
0
 public static void DoDbOperation(ICrudable x)
 {
     x.CreateDb();
     x.ReadDb();
     x.UpdateDb();
     x.DeleteDb();
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="service"></param>
 /// <param name="symmetricEncryptionKey"></param>
 public CrudEncrypt(ICrudable <StorableAsByteArray <TModel, TId>, TId> service, byte[] symmetricEncryptionKey)
     : base(symmetricEncryptionKey)
 {
     InternalContract.RequireNotNull(service, nameof(service));
     InternalContract.RequireNotNull(symmetricEncryptionKey, nameof(symmetricEncryptionKey));
     _service     = new CrudPassThrough <StorableAsByteArray <TModel, TId>, TId>(service);
     _convenience = new CrudConvenience <TModel, TModel, TId>(this);
 }
Esempio n. 6
0
 public static void DoDbOperation(ICrudable icrudable)
 {
     Console.WriteLine("In side DoDbOperation");
     icrudable.Create();
     icrudable.Read();
     icrudable.Delete();
     icrudable.Update();
 }
Esempio n. 7
0
 public static void DoDbOpperation(ICrudable crudOp)
 {
     Console.WriteLine("Inside Db operation");
     crudOp.Create();
     crudOp.Read();
     crudOp.Update();
     crudOp.Delete();
 }
Esempio n. 8
0
 public static void DoDbOperation(ICrudable crud)
 {
     Console.WriteLine("Doing db operations");
     crud.Create();
     crud.Read();
     crud.Update();
     crud.Delete();
 }
Esempio n. 9
0
 public static void PrintInfo(ICrudable crudable)
 {
     crudable.Add();
     crudable.Update();
     crudable.Delete();
     crudable.Read();
     Console.WriteLine();
 }
Esempio n. 10
0
 /// <summary>
 /// If <paramref name="service"/> doesn't implement <typeparamref name="T"/>, an exception is thrown.
 /// </summary>
 /// <param name="service">The service that must implement <typeparamref name="T"/>.</param>
 /// <typeparam name="T">The type that <paramref name="service"/> must implement.</typeparam>
 /// <returns></returns>
 /// <exception cref="FulcrumNotImplementedException">Thrown if <paramref name="service"/> doesn't implement <typeparamref name="T"/>.</exception>
 public static T GetImplementationOrThrow <T>(ICrudable service) where T : ICrudable
 {
     if (service is T implemented)
     {
         return(implemented);
     }
     throw new FulcrumNotImplementedException($"The service {service.GetType()} does not implement {typeof(T).Name}");
 }
Esempio n. 11
0
 /// <summary>
 /// If <paramref name="service"/> doesn't implement <typeparamref name="T"/>, an exception is thrown.
 /// </summary>
 /// <param name="service">The service that must implement <typeparamref name="T"/>.</param>
 /// <typeparam name="T">The type that <paramref name="service"/> must implement.</typeparam>
 /// <returns></returns>
 /// <exception cref="FulcrumNotImplementedException">Thrown if <paramref name="service"/> doesn't implement <typeparamref name="T"/>.</exception>
 public static T GetImplementationOrThrow <T>(ICrudable service) where T : ICrudable
 {
     InternalContract.RequireNotNull(service, nameof(service));
     if (service is T implemented)
     {
         return(implemented);
     }
     throw new FulcrumNotImplementedException(
               $"The service {service.GetType()} does not implement {typeof(T).Name}");
 }
Esempio n. 12
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World, I`m mapping!");

            // Mapping example.
            var students = ICrudable.GetAll <Student>();

            foreach (var student in students)
            {
                var viewModel = StudentViewModel.Map(student);
                Console.WriteLine($"{viewModel.UniqName} - {viewModel.AvgMark}");
            }

            Console.ReadKey();
        }
 /// <inheritdoc />
 public SlaveToMasterToServerTranslator(ICrudable <TModel, string> service,
                                        System.Func <string> getServerNameMethod, ITranslatorService translatorService)
     : base(service, getServerNameMethod, translatorService)
 {
 }
 /// <inheritdoc />
 public CrudClientTranslator(ICrudable service, string idConceptName,
                             System.Func <string> getClientNameMethod, ITranslatorService translatorService)
     : base(service, idConceptName, getClientNameMethod, translatorService)
 {
 }
Esempio n. 15
0
 /// <summary>
 /// Constructor for TOneModel that does not implement <see cref="IUniquelyIdentifiable{TId}"/>, or when you want to specify your own GetKey() method.
 /// </summary>
 /// <param name="service"></param>
 /// <param name="cache"></param>
 /// <param name="getIdDelegate"></param>
 /// <param name="flushCacheDelegateAsync"></param>
 /// <param name="options"></param>
 public SlaveToMasterAutoCache(ICrudable service,
                               GetIdDelegate <TManyModel, SlaveToMasterId <TId> > getIdDelegate, IDistributedCache cache,
                               FlushCacheDelegateAsync flushCacheDelegateAsync = null, AutoCacheOptions options = null)
     : base(service, getIdDelegate, cache, flushCacheDelegateAsync, options)
 {
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="service">The crud class to pass things down to.</param>
 public SlaveToMasterPassThrough(ICrudable service)
     : base(service)
 {
 }
Esempio n. 17
0
 public EmployeesController()
 {
     employeesrepository = new Employeerepository();
     postionrepository   = new Positionrepository();
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="service">The crud class to pass things down to.</param>
 public CrudPassThrough(ICrudable <TModel, TId> service)
     : base(service)
 {
 }
 /// <inheritdoc />
 public CrudSlaveToMasterControllerHelper(ICrudable <TModel, string> logic)
     : base(logic)
 {
 }
Esempio n. 20
0
 /// <summary>
 /// Constructor
 /// </summary>
 public SlaveToMasterMapper(ICrudable <TServerModel, TServerId> service, IMappable <TClientModel, TServerModel> mapper)
     : base(service, mapper)
 {
 }
Esempio n. 21
0
 public UnitOfMeasuresController()
 {
     unitsrepo = new UnitOfMeasurerepository();
 }
Esempio n. 22
0
 /// <inheritdoc />
 public CrudFromServerTranslator(ICrudable service, string idConceptName,
                                 System.Func <string> getServerNameMethod)
     : base(service, idConceptName, getServerNameMethod)
 {
 }
 public IngredientsController()
 {
     ingredientsrepo      = new Ingredientsrepository();
     rawMaterialrepi      = new RawMaterialsrepository();
     finishedProductsrepo = new FinProductrepository();
 }
Esempio n. 24
0
 /// <inheritdoc />
 public SlaveToMasterClientTranslator(ICrudable <TModel, string> service,
                                      string masterIdConceptName, string slaveIdConceptName, System.Func <string> getClientNameMethod,
                                      ITranslatorService translatorService)
     : base(service, masterIdConceptName, slaveIdConceptName, getClientNameMethod, translatorService)
 {
 }
Esempio n. 25
0
 /// <inheritdoc />
 public CrudController(ICrudable <TModel, string> logic)
     : base(logic)
 {
 }
 /// <summary>
 /// Constructor
 /// </summary>
 public CrudManyToOneDefaultController(ICrudable <TModel, string> logic)
     : base(logic)
 {
 }
 /// <inheritdoc />
 public ManyToOneToServerTranslator(ICrudable <TModel, string> service, string idConceptName,
                                    System.Func <string> getServerNameMethod, ITranslatorService translatorService)
     : base(service, idConceptName, getServerNameMethod, translatorService)
 {
 }
Esempio n. 28
0
 public List <Mark> LoadMarks() => ICrudable.GetAll <Mark>(x => x.StudentId == Id).ToList();
Esempio n. 29
0
 /// <summary>
 /// Constructor for TModel that does not implement <see cref="IUniquelyIdentifiable{TId}"/>, or when you want to specify your own GetKey() method.
 /// </summary>
 /// <param name="service"></param>
 /// <param name="cache"></param>
 /// <param name="getIdDelegate"></param>
 /// <param name="flushCacheDelegateAsync"></param>
 /// <param name="options"></param>
 public CrudAutoCache(ICrudable service, GetIdDelegate <TModel, TId> getIdDelegate,
                      IDistributedCache cache, FlushCacheDelegateAsync flushCacheDelegateAsync = null,
                      AutoCacheOptions options = null)
     : base(service, getIdDelegate, cache, flushCacheDelegateAsync, options)
 {
 }
 /// <summary>
 /// Constructor for TModel that implements <see cref="IUniquelyIdentifiable{TId}"/>.
 /// </summary>
 /// <param name="service"></param>
 /// <param name="cache"></param>
 /// <param name="flushCacheDelegateAsync"></param>
 /// <param name="options"></param>
 public CrudAutoCache(ICrudable <TModel, TId> service, IDistributedCache cache,
                      FlushCacheDelegateAsync flushCacheDelegateAsync = null, AutoCacheOptions options = null)
     : this(service, item => ((IUniquelyIdentifiable <TId>)item).Id, cache, flushCacheDelegateAsync, options)
 {
 }