示例#1
0
 public UserRepository(ExtraEdgeStoreDBContext extraEdgeStoreDBContext, ClientDBContext clientDB,
                       IMemoryCache memoryCache)
 {
     _extraEdgeStoreDBContext = extraEdgeStoreDBContext;
     _clientDBContext         = clientDB;
     _memoryCache             = memoryCache;
 }
示例#2
0
 public int Post(Clients client)
 {
     using (ClientDBContext dbContext = new ClientDBContext())
     {
         dbContext.Clients.Add(client);
         return(dbContext.SaveChanges());
     }
 }
示例#3
0
 public int Delete(int id)
 {
     using (ClientDBContext dbContext = new ClientDBContext())
     {
         var client = dbContext.Clients.Find(id);
         dbContext.Clients.Remove(client);
         return(dbContext.SaveChanges());
     }
 }
示例#4
0
 public int Put(int id, Clients client)
 {
     using (ClientDBContext dbContext = new ClientDBContext())
     {
         var client1 = dbContext.Clients.Find(id);
         client1.first_name             = client.first_name;
         client1.last_name              = client.last_name;
         client1.birth_day              = client.birth_day;
         dbContext.Entry(client1).State = System.Data.Entity.EntityState.Modified;
         return(dbContext.SaveChanges());
     }
 }
 public StoreClientControllerUnitTest()
 {
     cache                 = new MemoryCache(new MemoryCacheOptions());
     dbContextOptions      = new DbOptionsExtraEdgeDgeFactory("ExtraEdge").ExtraEdgeStoreDBContextOption;
     extraEdgeDB           = new ExtraEdgeStoreDBContext(dbContextOptions);
     clientDBContextOption = new DbOptionsExtraEdgeDgeFactory("ClientDB").ClientDBContextOption;
     clientDB              = new ClientDBContext(clientDBContextOption);
     encode                = new Mock <HtmlEncoder>().Object;
     mapperMock            = new MapperConfiguration(mc =>
     {
         mc.AddProfile(new MapProfile());
     }).CreateMapper();
     storeRepository = new StoreReposiotry(extraEdgeDB, clientDB);
     storeService    = new Mock <StoreService>(storeRepository, mapperMock);
     storeController = new StoreController(storeService.Object, cache);
 }
 public ClientsController(ClientDBContext context)
 {
     _context = context;
 }
示例#7
0
 public UserRepository(ClientDBContext _context)
 {
     context = _context;
 }
示例#8
0
        public IEnumerable <Clients> Find([FromUri] int?client_id     = null, [FromUri] string first_name        = null,
                                          [FromUri] string last_name  = null, [FromUri] DateTime?birth_day_start = null, [FromUri] DateTime?birth_day_end = null,
                                          [FromUri] int skip          = 0, [FromUri] int take = int.MaxValue,
                                          [FromUri] string sort_field = "id", [FromUri] string sort = "asc")
        {
            using (ClientDBContext dbContext = new ClientDBContext())
            {
                var clients = dbContext.Clients.Where(e => (e.client_id == client_id || client_id == null) &&
                                                      (e.first_name.Contains(first_name) || first_name == null) &&
                                                      (e.last_name.Contains(last_name) || last_name == null) &&
                                                      (e.birth_day >= birth_day_start || birth_day_start == null) &&
                                                      (e.birth_day <= birth_day_end || birth_day_end == null));

                IEnumerable <Clients> sorted = null;
                switch (sort_field)
                {
                case "id":
                    if (sort != "desc")
                    {
                        sorted = clients.OrderBy(e => e.client_id);
                    }
                    else
                    {
                        sorted = clients.OrderByDescending(e => e.client_id);
                    } break;

                case "first_name":
                    if (sort != "desc")
                    {
                        sorted = clients.OrderBy(e => e.first_name);
                    }
                    else
                    {
                        sorted = clients.OrderByDescending(e => e.first_name);
                    } break;

                case "last_name":
                    if (sort != "desc")
                    {
                        sorted = clients.OrderBy(e => e.last_name);
                    }
                    else
                    {
                        sorted = clients.OrderByDescending(e => e.last_name);
                    } break;

                case "birth_day":
                    if (sort != "desc")
                    {
                        sorted = clients.OrderBy(e => e.birth_day);
                    }
                    else
                    {
                        sorted = clients.OrderByDescending(e => e.birth_day);
                    } break;

                default: sorted = clients.OrderBy(e => e.client_id); break;
                }
                return(sorted.Skip(skip).Take(take).ToList());
            }
        }
 public ApplicationConfigurationRepository(ClientDBContext _clientDBContext)
 {
     clientDBContext = _clientDBContext;
 }
示例#10
0
 public StoreReposiotry(ExtraEdgeStoreDBContext extraEdgeStoreDBContext, ClientDBContext clientDBContext)
 {
     _extraEdgeStoreDBContext = extraEdgeStoreDBContext;
     _clientDBContext         = clientDBContext;
 }
示例#11
0
 public ClientController(ClientDBContext cdb)
 {
     _cdb = cdb;
 }