public void ReturnMaintenanceClientType()
 {
     using (var db = new CrudContext())
       {
     Assert.IsInstanceOf < ClientPatientManagement.Core.Model.Client > (db.Clients.FirstOrDefault());
       }
 }
 public void GetClientList()
 {
     using (var db = new CrudContext())
     {
         Assert.IsNotEmpty(db.Clients.ToList());
     }
 }
 public void ReturnMaintenanceClientType()
 {
     using (var db = new CrudContext())
     {
         Assert.IsInstanceOf <ClientPatientManagement.Core.Model.Client> (db.Clients.FirstOrDefault());
     }
 }
 public ActionResult AddPerson(PersonModel personModel)
 {
     try
     {
         using (CrudContext db = new CrudContext())
         {
             var teacher = new Teacher()
             {
                 Address = new Address()
                 {
                     Street = personModel.Street,
                     City   = new City()
                     {
                         Id = personModel.CityId,
                         // CountryId = 1
                     }
                 },
                 Name  = personModel.Name,
                 Email = personModel.Email
             };
             db.Entry(teacher.Address.City).State = EntityState.Unchanged;
             db.Persons.Add(teacher);
             db.SaveChanges();
             return(Json(true, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         return(Json(ex.Message, JsonRequestBehavior.AllowGet));
     }
 }
 public HomeController(CrudContext context, INewsService newsService, IGameService gameService, IReviewService reviewService)
 {
     _newsService   = newsService;
     _gameService   = gameService;
     _reviewService = reviewService;
     _context       = context;
 }
Esempio n. 6
0
        // Controller constructor
        public AdhocController(CrudContext context, IHttpContextAccessor httpContextAccessor)
        {
            _contextAdhoc = context;
            this.ipAddr   = httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress.ToString();

            if (ipAddr == "::1")                // when using localhost, IP is ::1.
            {
                this.ipAddr = "142.134.88.171"; // default IP Address for HRM in place for localhost
            }
            else
            {
                this.ipAddr = httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress.ToString();
            }

            // use ipstack web service to translate ip address to location
            string url     = "http://api.ipstack.com/" + ipAddr + "?access_key=<your key>";
            var    request = WebRequest.Create(url);

            using (WebResponse wrs = request.GetResponse())
                using (Stream stream = wrs.GetResponseStream())
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        string json = reader.ReadToEnd();
                        var    obj  = JObject.Parse(json);
                        city       = (string)obj["city"];
                        latitude   = (double)obj["latitude"];
                        longtitude = (double)obj["longitude"];
                        ipAddr     = city + " " + latitude + " " + longtitude;
                    }
        }
Esempio n. 7
0
        public Repository(CrudContext context, IExceptionLogger logger)
        {
            _context = context;
            _dbSet   = context.Set <TEntity>();

            _logger = logger;
        }
Esempio n. 8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, CrudContext entityManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseWebSockets();
            app.UseMiddleware <RequestFilter> ();
            app.UseMvc();
            String root = Path.Combine(Directory.GetCurrentDirectory(), "src/main/webapp");

            if (Directory.Exists(root))
            {
                app.UseFileServer(new FileServerOptions {
                    FileProvider = new PhysicalFileProvider(root)
                });
            }
            else
            {
                Console.WriteLine("Directory fail : " + root);
            }

            //			app.UseResponseCompression();
            //			app.UseMvcWithDefaultRoute();
            RequestFilter.UpdateCrudServices(entityManager);
        }
 public void GetClientList()
 {
     using (var db = new CrudContext())
       {
     Assert.IsNotEmpty(db.Clients.ToList());
       }
 }
Esempio n. 10
0
 public TestDbContextFixture()
 {
     Db          = new TestDbContext();
     CrudContext = new CrudContext <TestDbContext>(Db, () => new System.Security.Claims.ClaimsPrincipal())
     {
         ReflectionRepository = ReflectionRepositoryFactory.Reflection
     };
 }
Esempio n. 11
0
 public AppCrud(CrudContext context,
                IProduto produtoDB,
                ICategoria categoriaDB)
 {
     _context     = context;
     _produtoDB   = produtoDB;
     _categoriaDB = categoriaDB;
 }
Esempio n. 12
0
 public ActionResult Retrive(UserModel user)
 {
     using (CrudContext db = new CrudContext())
     {
         var output = db.user.ToList();
         return(View(output));
     }
 }
Esempio n. 13
0
        public void StartUp()
        {
            var optionsBuilder = new DbContextOptionsBuilder <CrudContext>();

            optionsBuilder.UseSqlite("Filename = Crud.db");

            _db = new CrudContext(optionsBuilder.Options);
        }
Esempio n. 14
0
        // Method implements logic data table
        public static List <object> TableChartData(CrudContext myContext, string pYear, string location, string service, string status, string overdue)
        {
            List <object> chartData = new List <object>();

            // 5. Filter by request category - Service tickets, Incidents, Adhoc

            chartData.Add(new object[] { "Request Category", "ID", "Submitted On", "Requestor",
                                         "Service/Priority", "Due Date", "Status", "Support Analyst", "Completed On" });

            switch (service)
            {
            case "Service requests":
                foreach (var item in myTicketsList)
                {
                    chartData.Add(new object[] { "Service request", item.ID, item.SubmittedDate,
                                                 item.RequestorID, item.RequiredService, item.RequiredByDate, item.Status, item.SupportAnalyst, item.CompletedDate });
                }
                break;

            case "Adhoc":
                foreach (var item in myAdhocsList)
                {
                    chartData.Add(new object[] { "Adhoc", item.ID, item.SubmittedDate,
                                                 item.RequestorID, item.Type, item.SubmittedDate, item.Status, item.SupportAnalyst, item.CompletedDate });
                }
                break;

            case "Incidents":
                foreach (var item in myIncidentsList)
                {
                    chartData.Add(new object[] { "Incident", item.ID, item.SubmittedDate,
                                                 item.RequestorID, item.Severity, item.SubmittedDate, item.Status, item.SupportAnalyst, item.CompletedDate });
                }
                break;

            default:
                foreach (var item in myTicketsList)
                {
                    chartData.Add(new object[] { "Service request", item.ID, item.SubmittedDate,
                                                 item.RequestorID, item.RequiredService, item.RequiredByDate, item.Status, item.SupportAnalyst, item.CompletedDate });
                }
                foreach (var item in myIncidentsList)
                {
                    chartData.Add(new object[] { "Incident", item.ID, item.SubmittedDate,
                                                 item.RequestorID, item.Severity, item.SubmittedDate, item.Status, item.SupportAnalyst, item.CompletedDate });
                }

                foreach (var item in myAdhocsList)
                {
                    chartData.Add(new object[] { "Adhoc", item.ID, item.SubmittedDate,
                                                 item.RequestorID, item.Type, item.SubmittedDate, item.Status, item.SupportAnalyst, item.CompletedDate });
                }
                break;
            }

            return(chartData);
        }
Esempio n. 15
0
 void Application_Start(object sender, EventArgs e)
 {
     // Code that runs on application startup
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     using (var ctx = new CrudContext())
     {
         new DatabaseInitializer().InitializeDatabase(ctx);
     }
 }
Esempio n. 16
0
        public ActionResult Updateuser(string id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            CrudContext db     = new CrudContext();
            var         output = db.user.Single(x => x.id == id);

            return(View(output));
        }
Esempio n. 17
0
        private static void ExplicitLoading()
        {
            using (var context = new CrudContext())
            {

                var projectCategory = context.ProjectCategories.First();
                context.Entry(projectCategory).Collection(pc => pc.Projects).Load();

                Console.WriteLine("project count for {0},{1}", projectCategory.Name, projectCategory.Projects.Count());

            }
        }
Esempio n. 18
0
 public ActionResult Updateusers(UserModel user)
 {
     if (ModelState.IsValid)
     {
         CrudContext db = new CrudContext();
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         ViewBag.Message = user.UserName + " successfully edited.";
         return(RedirectToAction("Retrive"));
     }
     return(View("Retrive"));
 }
Esempio n. 19
0
 public void Create()
 {
     try
     {
         var db        = new CrudContext();
         var employees = db.Set <Employee>().ToList();
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
 }
Esempio n. 20
0
 private static void DeleteProjectCategory()
 {
     int Id;
     using (var context = new CrudContext())
     {
         var projectCategoies  = context.ProjectCategories.Where(c => c.Name == "Internal").ToList();
         foreach (var projectCategory in projectCategoies)
         {
             context.ProjectCategories.Remove(projectCategory);
         }
         context.SaveChanges();
     }
 }
Esempio n. 21
0
        private static void CreateDataBase()
        {
            try
            {
                var context = new CrudContext();
                context.Database.Initialize(true);
            }
            catch (Exception w)
            {

                throw;
            }
        }
Esempio n. 22
0
 public async Task <string> Inserir(CrudContext context, Categorium obj)
 {
     try
     {
         var result = context.Categoria.Add(obj);
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
     return("");
 }
Esempio n. 23
0
 public async Task <string> Inserir(CrudContext context, Entities.Produto obj)
 {
     try
     {
         var result = context.Produtos.Add(obj);
         context.SaveChanges();
         return("");
     }
     catch (Exception ex)
     {
         return("Erro ao inserir o registro");
     }
     return("");
 }
Esempio n. 24
0
 public async Task <string> Atualizar(CrudContext context, Entities.Produto obj)
 {
     try
     {
         var result = context.Produtos.Update(obj);
         context.SaveChanges();
         return("");
     }
     catch (Exception ex)
     {
         return("Erro ao atualizar o registro");
     }
     return("");
 }
Esempio n. 25
0
        public async Task <string> Apagar(CrudContext context, int id)
        {
            try
            {
                var cat = await Listar(context, id);

                context.Categoria.Remove(cat.First());
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
            return("");
        }
Esempio n. 26
0
        public async Task <string> Apagar(CrudContext context, int id)
        {
            try
            {
                var prod = await Listar(context, id, null);

                context.Produtos.Remove(prod.First());
                context.SaveChanges();
                return("ok");
            }
            catch (Exception ex)
            {
                return("Erro ao apagar registro");
            }
        }
Esempio n. 27
0
 public async Task <List <Entities.Produto> > Listar(CrudContext context, int id, string nome)
 {
     try
     {
         var result = context.Produtos.FromSqlInterpolated($"exec sp_produtoSel @int_idProduto = {id}, @str_nome = {nome}").ToList();
         if (result.Count() > 0)
         {
             return(result);
         }
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
     return(new List <Entities.Produto>());
 }
Esempio n. 28
0
        private static void EagerLoading()
        {
            using (var context = new CrudContext())
            {
                var project1 = context.Projects.Include(p => p.Issues).ToList();
                var project2 = context.Projects.Include("Issues").ToList();
                var projectCategory3 = context.ProjectCategories.Include("Projects.Issues").ToList();

                 var projectCategory4 = context.ProjectCategories
                     .Where(pc=>pc.Projects.Any())
                     //.Include(pc => pc.Projects.Select(p => p.Issues.Select(w => w.UserProfile)))
                     .ToList()          ;
                 var projectCategory = projectCategory4[0];

            }
        }
Esempio n. 29
0
        public ActionResult Create(UserModel account)
        {
            if (ModelState.IsValid)
            {
                using (CrudContext db = new CrudContext())
                {
                    db.user.Add(account);
                    db.SaveChanges();
                }

                ModelState.Clear();

                ViewBag.Message = account.UserName + " successfully created.";
            }
            return(View());
        }
Esempio n. 30
0
        public ActionResult RemoveUser(string id, int y = 0)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            CrudContext db     = new CrudContext();
            var         output = db.user.Single(x => x.id == id);

            if (output == null)
            {
                return(HttpNotFound());
            }

            return(View());
        }
Esempio n. 31
0
        public async Task <List <Categorium> > Listar(CrudContext context, int id)
        {
            try
            {
                var param  = new SqlParameter("@int_idCategoria", id);
                var result = await context.Categoria.FromSqlRaw("exec sp_CategoriaSel @int_idCategoria", param).ToListAsync();

                if (result.Count() > 0)
                {
                    return(result);
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
            return(new List <Entities.Categorium>());
        }
Esempio n. 32
0
        /*
         * Method sets 4 filter variables - Year Submitted, Location, Service Category, Request Status, Overdue Status
         * This prevents from writing repetitive code for all methods responsible for visiuals in the Analytics Area as
         * all visuals are affected by the same set of filters.
         */
        public static void setFilterParameters(CrudContext myContext, string pYear, string location, string service, string status, string overdue)
        {
            myTicketsList   = myContext.Tickets.ToList();
            myIncidentsList = myContext.Incidents.ToList();
            myAdhocsList    = myContext.Adhocs.ToList();

            success = Int32.TryParse(pYear, out year);

            // 1.Filter by Year Submitted
            if (pYear != "All")
            {
                if (success)
                {
                    myTicketsList   = myTicketsList.FindAll(x => x.SubmittedDate.Year == year);
                    myIncidentsList = myIncidentsList.FindAll(x => x.SubmittedDate.Year == year);
                    myAdhocsList    = myAdhocsList.FindAll(x => x.SubmittedDate.Year == year);
                }
            }
            // 2. Filter by Location
            if (location != "All")
            {
                myTicketsList   = myTicketsList.FindAll(x => x.requestLocation == location);
                myIncidentsList = myIncidentsList.FindAll(x => x.requestLocation == location);
                myAdhocsList    = myAdhocsList.FindAll(x => x.requestLocation == location);
            }
            // 3. Filter by Status
            if (status != "All")
            {
                myTicketsList   = myTicketsList.FindAll(x => x.Status == status);
                myIncidentsList = myIncidentsList.FindAll(x => x.Status == status);
                myAdhocsList    = myAdhocsList.FindAll(x => x.Status == status);
            }

            DateTime todayDate = System.DateTime.Today;

            // 4. Filter by overdue status
            if (overdue != "All")
            {
                myTicketsList   = myTicketsList.FindAll(x => (x.CompletedDate > x.RequiredByDate) || (x.Status != "Closed" && x.Status != "Cancelled" && todayDate > x.RequiredByDate));
                myIncidentsList = myIncidentsList.FindAll(x => x.CompletedDate > x.SubmittedDate.AddHours(4));
                myAdhocsList    = myAdhocsList.FindAll(x => (x.CompletedDate > x.RequiredByDate) || (x.Status != "Closed" && x.Status != "Cancelled" && todayDate > x.RequiredByDate));
            }
        }
Esempio n. 33
0
        public void TestPraseHolder()
        {
            DatabaseTestClass databaseTestClass = new DatabaseTestClass();

            var tryEntity = new ServiceUser()
            {
                UserName = "******", Password = "******"
            };
            var tryEntity2 = new ServiceUser()
            {
                UserName = "******", Password = "******"
            };

            var  config  = new CrudContext().GetProperty(CrudEnum.GetLogin);
            bool answer  = databaseTestClass.ShowExeculteLog(config, tryEntity);
            bool answer2 = databaseTestClass.ShowExeculteLog(config, tryEntity2);

            Assert.True(answer && !answer2);
        }
Esempio n. 34
0
        public ActionResult RemoveUser(string id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            CrudContext db     = new CrudContext();
            var         output = db.user.Single(x => x.id == id);

            if (output == null)
            {
                return(HttpNotFound());
            }

            db.user.Remove(output);
            db.SaveChanges();

            return(RedirectToAction("Retrive"));
        }
Esempio n. 35
0
        private void SetAutofacContainer()
        {
            var builder = new ContainerBuilder();

            builder.RegisterControllers(Assembly.GetExecutingAssembly());


            var data = Assembly.Load("Data");

            builder.RegisterAssemblyTypes(data);

            var domain = Assembly.Load("Domain");

            builder.RegisterAssemblyTypes(domain);

            var application = Assembly.Load("Application");

            builder.RegisterAssemblyTypes(application);

            var x = new CrudContext();

            builder.Register <CrudContext>(c => x);
            builder.Register <CustomUserStore>(c => new CustomUserStore(x)).AsImplementedInterfaces();
            builder.Register <IdentityFactoryOptions <ApplicationUserManager> >(c => new IdentityFactoryOptions <ApplicationUserManager>()
            {
                DataProtectionProvider = new Microsoft.Owin.Security.DataProtection.DpapiDataProtectionProvider("ApplicationName")
            });
            builder.RegisterType <ApplicationUserManager>();
            builder.RegisterType <CrudContext>().InstancePerLifetimeScope();
            builder.RegisterType <CommentService>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <NewsService>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <ReviewService>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <RateService>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <UserService>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <GameService>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterFilterProvider();

            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
Esempio n. 36
0
        private static void GetProject1()
        {
            using (var context = new CrudContext())
            {
                var project = context.Projects.Where(p => p.Issues.Any())
                    .Select(p =>
                        new { Project=p.Name, ProjectCategory = p.ProjectCategoryId });

            }
        }
Esempio n. 37
0
        private static void InsertProjectCategory_Project()
        {
            try
            {
                var status = GetStatus();
                var projectCategory = new ProjectCategory
                {
                    Name = "Internal",

                };
                var project = new Project
                {
                    Name = "Jira1",
                    CompanyId = 1,
                    //ProjectId = Guid.NewGuid(),
                    //Works = {new Work(Guid.NewGuid()) {StatusId=status[0].StatusId,  TimeRange_Start=DateTime.Now.AddDays(-5),TimeRange_End=DateTime.Now.AddDays(-4) },
                    //    new Work(Guid.NewGuid()) {StatusId=status[0].StatusId, TimeRange_Start=DateTime.Now.AddDays(-3),TimeRange_End=DateTime.Now.AddDays(-2) }}
                };
                //project.ProjectCategory = projectCategory;
                projectCategory.Projects.Add(project);
                using (var context = new CrudContext())
                {
                    context.ProjectCategories.Add(projectCategory);
                    context.SaveChanges();
                }
            }
            catch (Exception e)
            {

                Console.WriteLine(e);
            }
        }
Esempio n. 38
0
        private static void UpdateProjectCategory()
        {
            int Id;
            using (var context = new CrudContext())
            {
                var projectCategory = context.ProjectCategories.FirstOrDefault(c => c.Name == "Internal");
                Id = projectCategory.Id;
                projectCategory.Description = "Internal projects";
                context.SaveChanges();

            }
            GetProjectCategory(Id);
        }
Esempio n. 39
0
        private static List<Status> GetStatus()
        {
            using (var context = new CrudContext())
            {
                return context.Status.ToList();

            }
        }
Esempio n. 40
0
 private static void InsertProjectCategory()
 {
     var projectCategory = new ProjectCategory { Name = "Internal" };
     using (var context = new CrudContext())
     {
         context.ProjectCategories.Add(projectCategory);
         context.SaveChanges();
     }
     GetProjectCategory(projectCategory.Id);
 }
Esempio n. 41
0
 public MyBehaviors(CrudContext <TContext> context) : base(context)
 {
 }
Esempio n. 42
0
        private static void GetProject2()
        {
            using (var context = new CrudContext())
            {

                var project = from p in context.Projects
                              where p.Issues.Any()
                    select new
                         { Project = p.Name, ProjectCategory = p.ProjectCategoryId };

            }
        }