Exemple #1
0
        public void Initialize()
        {
            var options = new DbContextOptionsBuilder <CoreDbContext>()
                          .UseInMemoryDatabase(databaseName: "UserDatabase")
                          .Options;

            _testUsers   = new List <User>();
            _testContext = new CoreDbContext(options);
            _testContext.Database.EnsureDeleted();

            for (var i = 0; i < 10; i++)
            {
                var newUser = ModelFakes.UserFake.Generate();
                _testContext.Add(newUser);
                _testContext.SaveChanges();
                _testUsers.Add(ObjectExtensions.Copy(_testContext.User.FirstOrDefault(u => u.Username.Equals(newUser.Username))));
            }

            _nonActiveUser        = ModelFakes.UserFake.Generate();
            _nonActiveUser.Active = false;
            _testContext.Add(_nonActiveUser);
            _testContext.SaveChanges();
            _testUsers.Add(ObjectExtensions.Copy(_testContext.User.FirstOrDefault(u => u.Username.Equals(_nonActiveUser.Username))));

            _testUserService = new UserService(_testContext);
        }
Exemple #2
0
        public void Initialize()
        {
            var options = new DbContextOptionsBuilder <CoreDbContext>()
                          .UseInMemoryDatabase(databaseName: "TherapyDatabase")
                          .Options;

            _testTherapyMains = new List <TherapyMain>();
            _testTherapies    = new List <Therapy>();
            _testContext      = new CoreDbContext(options);
            _testContext.Database.EnsureDeleted();

            for (var i = 0; i < 10; i++)
            {
                var newTherapyMain = ModelFakes.TherapyMainFake.Generate();
                _testContext.Add(newTherapyMain);
                _testContext.SaveChanges();
                _testTherapyMains.Add(ObjectExtensions.Copy(newTherapyMain));


                var newTherapy = ModelFakes.TherapyFake.Generate();
                newTherapy.Type = newTherapyMain.Type;
                _testContext.Add(newTherapy);
                _testContext.SaveChanges();
                _testTherapies.Add(ObjectExtensions.Copy(newTherapy));
            }

            _nonActiveTherapy        = ModelFakes.TherapyFake.Generate();
            _nonActiveTherapy.Type   = _testTherapyMains[0].Type;
            _nonActiveTherapy.Active = false;
            _testContext.Add(_nonActiveTherapy);
            _testContext.SaveChanges();

            _testTherapyService = new TherapyService(_testContext);
        }
Exemple #3
0
        public void Initialize()
        {
            var options = new DbContextOptionsBuilder <CoreDbContext>()
                          .UseInMemoryDatabase(databaseName: "UserDatabase")
                          .Options;

            _testHoursWorked = new List <HoursWorked>();
            _testContext     = new CoreDbContext(options);
            _testContext.Database.EnsureDeleted();

            for (var i = 0; i < 10; i++)
            {
                var newUser = ModelFakes.UserFake.Generate();
                _testContext.Add(newUser);
                _testContext.SaveChanges();

                var newHoursWorked = ModelFakes.HoursWorkedFake.Generate();
                newHoursWorked.User   = newUser;
                newHoursWorked.UserId = newUser.UserId;
                _testContext.Add(newHoursWorked);
                _testContext.SaveChanges();
                _testHoursWorked.Add(ObjectExtensions.Copy(newHoursWorked));
            }

            _testHoursWorkedService = new HoursWorkedService(_testContext);
        }
Exemple #4
0
        public void Initialize()
        {
            var options = new DbContextOptionsBuilder <CoreDbContext>()
                          .UseInMemoryDatabase(databaseName: "LocationDatabase")
                          .Options;

            _testLocations = new List <Location>();
            _testContext   = new CoreDbContext(options);
            _testContext.Database.EnsureDeleted();

            for (var i = 0; i < 10; i++)
            {
                var newLocation = ModelFakes.LocationFake.Generate();
                _testContext.Add(newLocation);
                _testContext.SaveChanges();
                _testLocations.Add(ObjectExtensions.Copy(newLocation));
            }

            _nonActiveLocation        = ModelFakes.LocationFake.Generate();
            _nonActiveLocation.Active = false;
            _testContext.Add(_nonActiveLocation);
            _testContext.SaveChanges();
            _testLocations.Add(ObjectExtensions.Copy(_nonActiveLocation));

            _testLocationService = new LocationService(_testContext);
        }
Exemple #5
0
        public void Initialize()
        {
            var options = new DbContextOptionsBuilder <CoreDbContext>()
                          .UseInMemoryDatabase(databaseName: "TherapyMainDatabase")
                          .Options;

            _testTherapyMains = new List <TherapyMain>();
            _testContext      = new CoreDbContext(options);
            _testContext.Database.EnsureDeleted();

            for (var i = 0; i < 10; i++)
            {
                var newTherapyMain = ModelFakes.TherapyMainFake.Generate();
                _testContext.Add(newTherapyMain);
                _testContext.SaveChanges();
                _testTherapyMains.Add(ObjectExtensions.Copy(_testContext.TherapyMain.FirstOrDefault(t => t.Type.Equals(newTherapyMain.Type))));
            }

            _nonActiveTherapyMain        = ModelFakes.TherapyMainFake.Generate();
            _nonActiveTherapyMain.Active = false;
            _testContext.Add(_nonActiveTherapyMain);
            _testContext.SaveChanges();
            _testTherapyMains.Add(ObjectExtensions.Copy(_testContext.TherapyMain.FirstOrDefault(t => t.Type.Equals(_nonActiveTherapyMain.Type))));

            _testTherapyMainService    = new TherapyMainService(_testContext);
            _testTherapyMainController = new TherapyMainController(_testTherapyMainService);
        }
Exemple #6
0
        public void Initialize()
        {
            var options = new DbContextOptionsBuilder <CoreDbContext>().UseInMemoryDatabase(databaseName: "RoomDatabase").Options;

            _testRooms   = new List <Room>();
            _testContext = new CoreDbContext(options);
            _testContext.Database.EnsureDeleted();

            for (var i = 0; i < 10; i++)
            {
                var newRoom = ModelFakes.RoomFake.Generate();
                _testContext.Add(newRoom);
                _testContext.SaveChanges();
                _testRooms.Add(ObjectExtensions.Copy(newRoom));
            }

            _nonActiveRooms        = ModelFakes.RoomFake.Generate();
            _nonActiveRooms.Active = false;
            _testContext.Add(_nonActiveRooms);
            _testContext.SaveChanges();
            _testRooms.Add(ObjectExtensions.Copy(_nonActiveRooms));

            _testRoomService    = new RoomService(_testContext);
            _testRoomController = new RoomController(_testRoomService);
        }
        private static void AddInternal(CoreDbContext context, IEntity entity)
        {
            if (entity is IDerivedEntity derived)
            {
                AddInternal(context, derived._BaseClone);
            }

            context.Add(entity);
        }
 public async Task ExecuteAsync()
 {
     if (!_context.Set <Tenant>().Any())
     {
         var tenantId = Guid.Parse(AuthRole.SuperAdminId);
         var tenant   = new Tenant(tenantId, "Medlatec", "*****@*****.**", "0369574322", "Nghĩa Dũng", true, "", "");
         _context.Add(tenant);
         // set tenant Pages
         if (!_context.Set <TenantPage>().Where(x => x.TenantId == tenantId).Any())
         {
             var pages = _context.Set <Page>().ToList();
             foreach (var page in pages)
             {
                 _context.Add(new TenantPage(tenantId, page.Id, false));
             }
         }
         _context.SaveChanges();
     }
 }
        public async Task <IActionResult> Create(int?id, [Bind("erro,descricao,solucao,obs,Id")] KnowBase knowBase, IFormFile[] file, string[] idAnexo)
        {
            if (ModelState.IsValid)
            {
                List <KnowBaseAnexos> listAnexo = new List <KnowBaseAnexos>();

                if (knowBase.Id == id)
                {
                    for (int i = 0; i < file.Length; i++)
                    {
                        using (var ms = new MemoryStream())
                        {
                            KnowBaseAnexos anexo = new KnowBaseAnexos();
                            file[i].CopyTo(ms);
                            anexo.arquivo = ms.ToArray();
                            anexo.nome    = file[i].FileName;
                            anexo.tipo    = file[i].ContentType;

                            listAnexo.Add(anexo);
                        }
                    }

                    knowBase.knowbaseanexo = listAnexo;

                    _context.Update(knowBase);
                    await _context.SaveChangesAsync();
                }
                else
                {
                    for (int i = 0; i < file.Length; i++)
                    {
                        using (var ms = new MemoryStream())
                        {
                            file[i].CopyTo(ms);
                            listAnexo.Add(new KnowBaseAnexos()
                            {
                                arquivo = ms.ToArray(),
                                nome    = file[i].Name,
                                tipo    = file[i].ContentType
                            });
                        }
                    }

                    knowBase.knowbaseanexo = listAnexo;

                    _context.Add(knowBase);
                    await _context.SaveChangesAsync();
                }
            }
            //ViewData["IdCliente"] = new SelectList(_context.clientes, "Id", "Id", knowBase.IdCliente);
            //ViewData["IdKnowLocais"] = new SelectList(_context.knowLocais, "Id", "Id", knowBase.IdKnowLocais);
            //ViewData["IdKnowProduto"] = new SelectList(_context.knowProduto, "Id", "Id", knowBase.IdKnowProduto);
            //return View(knowBase);
            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Create([Bind("IdKnowbase,arquivo,tipo,nome,Id,DataInclusion,UserName")] KnowBaseAnexos knowBaseAnexos)
        {
            if (ModelState.IsValid)
            {
                _context.Add(knowBaseAnexos);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(knowBaseAnexos));
        }
        public async Task <IActionResult> Create([Bind("Id,Text,Score")] Answer answer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(answer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(answer));
        }
Exemple #12
0
        public async Task <IActionResult> Create([Bind("OrderDate,Id,Version")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(order));
        }
        public async Task <IActionResult> Create([Bind("nome,versao,Id,DataInclusion,UserName")] KnowProduto knowProduto)
        {
            if (ModelState.IsValid)
            {
                _context.Add(knowProduto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(knowProduto));
        }
Exemple #14
0
        public async Task <IActionResult> Create([Bind("Firstname,Lastname")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(customer));
        }
Exemple #15
0
        public void CreateUser(UserInfo userInfo)
        {
            if (userInfo == null)
            {
                throw new ArgumentNullException();
            }

            _dbContext.Add(userInfo);

            _dbContext.SaveChanges();
        }
        public async Task <IActionResult> Create([Bind("IdCliente,arquivo,tipo,nome,tamanho,Id,DataInclusion,UserName")] ClienteAnexos clienteAnexos)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clienteAnexos);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCliente"] = new SelectList(_context.clientes, "Id", "Id", clienteAnexos.IdCliente);
            return(View(clienteAnexos));
        }
Exemple #17
0
        public async Task <IActionResult> Create([Bind("IdCliente,link,usuario,senha,Id")] ClienteLinks clienteLinks)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clienteLinks);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCliente"] = new SelectList(_context.clientes, "Id", "Id", clienteLinks.IdCliente);
            return(View(clienteLinks));
        }
Exemple #18
0
        public async Task <IActionResult> Create([Bind("IdCliente,descricao,ip,usuario,senha,obs,Id,DataInclusion,UserName")] ClienteConexoes clienteConexoes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clienteConexoes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCliente"] = new SelectList(_context.clientes, "Id", "Id", clienteConexoes.IdCliente);
            return(View(clienteConexoes));
        }
Exemple #19
0
 public IActionResult EFWithTranscation()
 {
     using (var trans = _dbContext.Database.BeginTransaction(_cap, true))
     {
         Order order = new Order();
         order.Name       = $"{((new Random().Next()%2==0) ?"香蕉":"橘子")}" + $"{new Random().Next(1,100)}斤";
         order.CreateDate = DateTime.Now;
         _cap.Publish <Order>("test_oder", order);
         _dbContext.Add(order);
         _dbContext.SaveChanges();
     }
     return(Ok());
 }
Exemple #20
0
        public void Initialize()
        {
            var options = new DbContextOptionsBuilder <CoreDbContext>()
                          .UseInMemoryDatabase(databaseName: "PermissionDatabase")
                          .Options;

            _testPermissions = new List <Permission>();
            _testUsers       = new List <User>();
            _testContext     = new CoreDbContext(options);
            _testContext.Database.EnsureDeleted();

            _userWithNoPermissions = ModelFakes.UserFake.Generate();
            _testUsers.Add(ObjectExtensions.Copy(_userWithNoPermissions));
            _testContext.Add(_userWithNoPermissions);
            _testContext.SaveChanges();

            for (var i = 0; i < 10; i++)
            {
                var newUser = ModelFakes.UserFake.Generate();
                _testContext.Add(newUser);
                _testContext.SaveChanges();
                _testUsers.Add(ObjectExtensions.Copy(newUser));

                var newPermission = ModelFakes.PermissionFake.Generate();
                _testContext.Add(newPermission);
                _testContext.SaveChanges();
                _testPermissions.Add(ObjectExtensions.Copy(newPermission));
            }

            _nonActiveUser        = ModelFakes.UserFake.Generate();
            _nonActiveUser.Active = false;
            _testContext.Add(_nonActiveUser);
            _testContext.SaveChanges();
            _testUsers.Add(ObjectExtensions.Copy(_nonActiveUser));

            _testPermissionService    = new PermissionService(_testContext);
            _testPermissionController = new PermissionController(_testPermissionService);
        }
 public async Task ExecuteAsync()
 {
     if (!_context.Set <Role>().Any())
     {
         var allRoles = new List <Role>
         {
             new Role(Guid.Parse(AuthRole.SuperAdminId), Guid.Parse(AuthRole.SuperAdminId), AuthRole.SuperAdmin, AuthRole.SuperAdmin, AuthRole.SuperAdmin)
         };
         foreach (var item in allRoles)
         {
             _context.Add(item);
         }
         _context.SaveChanges();
     }
 }
Exemple #22
0
        public async Task <IActionResult> Create(int?id, [Bind("nome,obs,Id")] Clientes clientes
                                                 , string[] link, string[] user, string[] pass, string[] nomelink, int?[] linkid
                                                 , string[] conexao_pass, string[] conexao_user, string[] conexao_ip, string[] conexao_desc, string[] obsConexao, int?[] conexao_id
                                                 , IFormFile[] file, string[] idAnexo)
        {
            if (ModelState.IsValid)
            {
                List <ClienteLinks>    cliLink    = new List <ClienteLinks>();
                List <ClienteAnexos>   cliAnexo   = new List <ClienteAnexos>();
                List <ClienteConexoes> cliConexao = new List <ClienteConexoes>();

                if (clientes.Id == id)
                {
                    try
                    {
                        for (int i = 0; i < linkid.Length; i++)
                        {
                            try
                            {
                                if (linkid[i].ToString() != null && !string.IsNullOrEmpty(linkid[i].ToString()))
                                {
                                    try
                                    {
                                        var idlink = string.IsNullOrEmpty(linkid[i].ToString());

                                        if (!string.IsNullOrEmpty(linkid[i].ToString()))
                                        {
                                            ClienteLinks clienteLinks = _context.clienteLinks.Find(linkid[i]);
                                            clienteLinks.link    = link[i];
                                            clienteLinks.senha   = pass[i];
                                            clienteLinks.usuario = user[i];
                                            clienteLinks.nome    = nomelink[i];

                                            cliLink.Add(clienteLinks);
                                        }
                                    }
                                    catch
                                    {
                                        cliLink.Add(new ClienteLinks()
                                        {
                                            link    = link[i],
                                            senha   = pass[i],
                                            usuario = user[i],
                                            nome    = nomelink[i]
                                        });
                                    }
                                }

                                clientes.clientelinks = cliLink;
                            }
                            catch
                            { }
                        }


                        for (int i = 0; i < conexao_id.Length; i++)
                        {
                            try
                            {
                                if (conexao_id[i].ToString() != null && !string.IsNullOrEmpty(conexao_id[i].ToString()))
                                {
                                    try
                                    {
                                        var id_conexao = string.IsNullOrEmpty(conexao_id[i].ToString());

                                        if (!string.IsNullOrEmpty(conexao_id[i].ToString()))
                                        {
                                            ClienteConexoes clicon = _context.clienteConexoes.Find(conexao_id[i]);

                                            clicon.descricao  = conexao_desc[i];
                                            clicon.senha      = conexao_pass[i];
                                            clicon.usuario    = conexao_user[i];
                                            clicon.ip         = conexao_ip[i];
                                            clicon.obsConexao = obsConexao[i];

                                            cliConexao.Add(clicon);
                                        }
                                    }
                                    catch
                                    {
                                        cliConexao.Add(new ClienteConexoes()
                                        {
                                            descricao  = conexao_desc[i],
                                            ip         = conexao_ip[i],
                                            senha      = conexao_pass[i],
                                            usuario    = conexao_user[i],
                                            obsConexao = obsConexao[i]
                                        });
                                    }
                                }

                                clientes.clienteconexao = cliConexao;
                            }
                            catch
                            { }
                        }

                        try
                        {
                            for (int a = 0; a < file.Length; a++)
                            {
                                try
                                {
                                    using (var ms = new MemoryStream())
                                    {
                                        ClienteAnexos anexo = new ClienteAnexos();
                                        file[a].CopyTo(ms);
                                        anexo.arquivo = ms.ToArray();
                                        anexo.nome    = file[a].FileName;
                                        anexo.tipo    = file[a].ContentType;

                                        cliAnexo.Add(anexo);
                                    }
                                }
                                catch
                                { }
                            }
                            clientes.clienteanexos = cliAnexo;
                        }
                        catch
                        { }

                        _context.Update(clientes);
                        await _context.SaveChangesAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (!ClientesExists(clientes.Id))
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw;
                        }
                    }



                    //return RedirectToAction(nameof(Edit));
                    //return RedirectToAction(nameof(Index));
                }
                else
                {
                    //_context.Add(clientes);
                    //List<ClienteLinks> cl = new List<ClienteLinks>();

                    for (int i = 0; i < link.Length; i++)
                    {
                        cliLink.Add(new ClienteLinks()
                        {
                            link    = link[i],
                            senha   = pass[i],
                            usuario = user[i],
                            nome    = nomelink[i]
                        });
                    }

                    for (int i = 0; i < conexao_desc.Length; i++)
                    {
                        cliConexao.Add(new ClienteConexoes()
                        {
                            descricao  = conexao_desc[i],
                            ip         = conexao_ip[i],
                            senha      = conexao_pass[i],
                            usuario    = conexao_user[i],
                            obsConexao = obsConexao[i]
                        });
                    }

                    for (int i = 0; i < file.Length; i++)
                    {
                        using (var ms = new MemoryStream())
                        {
                            file[i].CopyTo(ms);
                            cliAnexo.Add(new ClienteAnexos()
                            {
                                arquivo = ms.ToArray(),
                                nome    = file[i].Name,
                                tipo    = file[i].ContentType
                            });
                        }
                    }


                    clientes.clientelinks = cliLink;

                    clientes.clienteconexao = cliConexao;

                    clientes.clienteanexos = cliAnexo;

                    var json = JsonConvert.SerializeObject(clientes);

                    _context.Add(clientes);

                    await _context.SaveChangesAsync();

                    //return RedirectToAction(nameof(Index));
                }
            }
            else
            {
                //Danger("Model Invalid!");
            }
            //Success("Cliente salvo com sucesso.");
            return(RedirectToAction(nameof(Index)));
            //return View(clientes);
        }
Exemple #23
0
 public void Add(Resturant resturant)
 {
     _context.Add(resturant);
 }
Exemple #24
0
        public async Task <IActionResult> CreateClientConnection(Clientes cliCon)
        {
            if (cliCon != null)
            {
                Clientes               cliente;
                List <ClienteLinks>    cliLink    = new List <ClienteLinks>();
                List <ClienteConexoes> cliConexao = new List <ClienteConexoes>();
                bool addSomething = false;

                try
                {
                    var clientes = _context.clientes.Include(c => c.clienteconexao);

                    if (!clientes.Where(s => s.nome == cliCon.nome).Any())
                    {
                        addSomething = true;
                        cliente      = new Clientes()
                        {
                            nome = cliCon.nome
                        };
                    }
                    else
                    {
                        cliente = clientes.Where(s => s.nome == cliCon.nome).FirstOrDefault();
                    }

                    foreach (var con in cliCon.clienteconexao)
                    {
                        if (!clientes.Where(s => s.clienteconexao.Where(c => c.descricao == con.descricao).Any()).Any())
                        {
                            addSomething = true;
                            cliConexao.Add(new ClienteConexoes()
                            {
                                descricao  = con.descricao,
                                ip         = con.ip,
                                senha      = con.senha,
                                usuario    = con.usuario,
                                obsConexao = con.obsConexao
                            });
                        }
                    }

                    foreach (var link in cliCon.clientelinks)
                    {
                        if (!clientes.Where(s => s.clientelinks.Where(c => c.link == link.link && c.cliente == cliente).Any()).Any())
                        {
                            addSomething = true;
                            cliLink.Add(new ClienteLinks()
                            {
                                nome    = link.nome,
                                senha   = link.senha,
                                usuario = link.usuario,
                                link    = link.link
                            });
                        }
                    }

                    cliente.clientelinks = cliLink;

                    cliente.clienteconexao = cliConexao;

                    if (!addSomething)
                    {
                        return(BadRequest("Cliente e Conexão já existem."));
                    }
                    else
                    {
                        _context.Add(cliente);

                        await _context.SaveChangesAsync();

                        return(Ok());
                    }
                }
                catch (Exception e)
                {
                    return(BadRequest(e));
                }
            }
            return(BadRequest());
        }
 public Restaurant Add(Restaurant restaurant)
 {
     context.Add(restaurant);
     context.SaveChanges();
     return(restaurant);
 }
Exemple #26
0
        public void Initialize()
        {
            var options = new DbContextOptionsBuilder <CoreDbContext>()
                          .UseInMemoryDatabase(databaseName: "TherapistEventDatabase")
                          .Options;

            _testContext = new CoreDbContext(options);
            _testContext.Database.EnsureDeleted();
            _testUsers               = new List <User>();
            _testTherapistEvents     = new List <TherapistEvent>();
            _testTargetStartDateTime = new DateTime(2010, 2, 8);
            _testTargetEndDateTime   = new DateTime(2010, 2, 12);

            for (var i = 0; i < 8; i++)
            {
                var newUser = ModelFakes.UserFake.Generate();
                _testContext.Add(newUser);
                _testContext.SaveChanges();
                _testUsers.Add(ObjectExtensions.Copy(newUser));

                Permission newPermission = new Permission
                {
                    UserId = newUser.UserId,
                    Role   = "therapist"
                };
                _testContext.Add(newPermission);
                _testContext.SaveChanges();

                var newTherapistEvent = ModelFakes.TherapistEventFake.Generate();
                newTherapistEvent.TherapistId = newUser.UserId;

                if (i <= 2)
                {
                    newTherapistEvent.StartTime = _testTargetStartDateTime.AddDays(i);
                    newTherapistEvent.EndTime   = _testTargetEndDateTime.AddDays(-1 * i);
                }

                _testContext.Add(newTherapistEvent);
                _testContext.SaveChanges();
                _testTherapistEvents.Add(ObjectExtensions.Copy(newTherapistEvent));
            }

            _testNonTherapistUser = ModelFakes.UserFake.Generate();
            _testContext.Add(_testNonTherapistUser);
            _testContext.SaveChanges();
            _testUsers.Add(ObjectExtensions.Copy(_testNonTherapistUser));

            var newEdgeTherapistEvent = ModelFakes.TherapistEventFake.Generate();

            newEdgeTherapistEvent.TherapistId = _testUsers[0].UserId;
            newEdgeTherapistEvent.StartTime   = _testTargetStartDateTime.AddDays(-1);
            _testContext.Add(newEdgeTherapistEvent);
            _testContext.SaveChanges();
            _testTherapistEvents.Add(ObjectExtensions.Copy(newEdgeTherapistEvent));

            newEdgeTherapistEvent             = ModelFakes.TherapistEventFake.Generate();
            newEdgeTherapistEvent.TherapistId = _testUsers[0].UserId;
            newEdgeTherapistEvent.EndTime     = _testTargetEndDateTime.AddDays(1);
            _testContext.Add(newEdgeTherapistEvent);
            _testContext.SaveChanges();
            _testTherapistEvents.Add(ObjectExtensions.Copy(newEdgeTherapistEvent));

            _nonActiveTherapistEvent           = ModelFakes.TherapistEventFake.Generate();
            _nonActiveTherapistEvent.Active    = false;
            _nonActiveTherapistEvent.StartTime = _testTargetStartDateTime;
            _nonActiveTherapistEvent.EndTime   = _testTargetEndDateTime;
            _testContext.Add(_nonActiveTherapistEvent);
            _testContext.SaveChanges();
            _testTherapistEvents.Add(ObjectExtensions.Copy(_nonActiveTherapistEvent));

            _testTherapistEvent = new TherapistEvent
            {
                StartTime   = DateTime.MinValue,
                EndTime     = DateTime.MaxValue,
                TherapistId = _testUsers[0].UserId
            };

            _testTherapistEventService    = new TherapistEventService(_testContext);
            _testTherapistEventController = new TherapistEventController(_testTherapistEventService);
        }
 public void Add(Product product)
 {
     context.Add(product);
     context.SaveChanges();
 }