public UserRepository(ExtraEdgeStoreDBContext extraEdgeStoreDBContext, ClientDBContext clientDB, IMemoryCache memoryCache) { _extraEdgeStoreDBContext = extraEdgeStoreDBContext; _clientDBContext = clientDB; _memoryCache = memoryCache; }
public int Post(Clients client) { using (ClientDBContext dbContext = new ClientDBContext()) { dbContext.Clients.Add(client); return(dbContext.SaveChanges()); } }
public int Delete(int id) { using (ClientDBContext dbContext = new ClientDBContext()) { var client = dbContext.Clients.Find(id); dbContext.Clients.Remove(client); return(dbContext.SaveChanges()); } }
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; }
public UserRepository(ClientDBContext _context) { context = _context; }
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; }
public StoreReposiotry(ExtraEdgeStoreDBContext extraEdgeStoreDBContext, ClientDBContext clientDBContext) { _extraEdgeStoreDBContext = extraEdgeStoreDBContext; _clientDBContext = clientDBContext; }
public ClientController(ClientDBContext cdb) { _cdb = cdb; }