Exemplo n.º 1
0
 public TaskPlanController(ILogger <TaskPlanController> logger, SqlLiteContext SqlLiteContext, QuartzStartup quartzStartup, FreeSqlFactory freeSqlFactory)
 {
     _SqlLiteContext = SqlLiteContext;
     _logger         = logger;
     _quartzStartup  = quartzStartup;
     _sqliteFSql     = freeSqlFactory.GetBaseSqlLite();
 }
        public ActionResult Admin(int employeeid)
        {
            List <MiddlewareViewModel> Middlewareviewmodellist = new List <MiddlewareViewModel>();
            List <Middleware>          employeemiddlewarelist  = MiddlewareService.GetByEmployee(employeeid);

            using var context = new SqlLiteContext();
            List <Middleware> middlewarelist = context.Middlewares.ToList();

            foreach (Middleware t in middlewarelist)
            {
                MiddlewareViewModel mvm = new MiddlewareViewModel();
                mvm.MiddlewareId = t.MiddlewareId;
                mvm.EmployeeId   = employeeid;
                mvm.Name         = t.Name;
                foreach (Middleware te in employeemiddlewarelist)
                {
                    if (t.MiddlewareId == te.MiddlewareId)
                    {
                        mvm.Connected = true;
                    }
                }
                Middlewareviewmodellist.Add(mvm);
            }
            var sortedlist = Middlewareviewmodellist.OrderBy(foo => foo.Name).ToList();
            var arv        = new BindEmployeeMiddlewareViewModel(sortedlist);

            return(View(arv));
        }
Exemplo n.º 3
0
 public HomeController(ILogger <HomeController> logger, SqlLiteContext SqlLiteContext, QuartzStartup quartzStartup)
 {
     //LogProvider.SetCurrentLogProvider(new AutoSchedule.Common.LogProvider());
     _SqlLiteContext = SqlLiteContext;
     _logger         = logger;
     _quartzStartup  = quartzStartup;
 }
Exemplo n.º 4
0
        // GET: Assigments/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            AssignmentViewModel assignmentviewmodel = new AssignmentViewModel();
            var       context   = new SqlLiteContext();
            Assigment assigment = await context.Assigments
                                  .FirstOrDefaultAsync(m => m.Id == id);

            if (assigment == null)
            {
                return(NotFound());
            }
            AssignmentViewModel avm = new AssignmentViewModel
            {
                Id          = assigment.Id,
                Employee    = EmployeeService.Get(assigment.Employeeid),
                Beskrivning = assigment.Beskrivning,
                Roll        = assigment.Roll,
                Teknik      = assigment.Teknik,
                Tid         = assigment.Tid,
                Uppdrag     = assigment.Uppdrag,
                Focus       = assigment.Focus
            };

            return(View(avm));
        }
Exemplo n.º 5
0
        public static Assigment Get(int id)
        {
            using var context = new SqlLiteContext();
            var assignment = context.Assigments.Find(id);

            return(assignment);
        }
Exemplo n.º 6
0
        public static List <Assigment> GetAllFocus(int employeeid)
        {
            using var context = new SqlLiteContext();
            var assignments = context.Assigments.Where(a => a.Employeeid == employeeid && a.Focus == true).ToList();

            return(assignments);
        }
Exemplo n.º 7
0
        public ActionResult Add(BindEmployeeTrainingViewModel arv)
        {
            SqlLiteContext context = new SqlLiteContext();

            for (int i = 0; i < arv.Trainings.Count(); i++)
            {
                var employeeTraining = context.EmployeeTrainings.Where(a => a.EmployeeId == arv.Trainings[i].EmployeeId && a.TrainingId == arv.Trainings[i].TrainingId).FirstOrDefault();

                if (arv.Trainings[i].Connected)
                {
                    if (employeeTraining == null)
                    {
                        var et = new EmployeeTraining();
                        et.EmployeeId = arv.Trainings[i].EmployeeId;
                        et.TrainingId = arv.Trainings[i].TrainingId;
                        var entity = context.EmployeeTrainings.Add(et);
                        entity.State = EntityState.Added;
                    }
                }
                else
                {
                    if (employeeTraining != null)
                    {
                        var entity = context.EmployeeTrainings.Remove(employeeTraining);
                        entity.State = EntityState.Deleted;
                    }
                }
            }
            context.SaveChanges();
            return(RedirectToAction("Cv", "Home", new { id = arv.Trainings[0].EmployeeId }));
        }
Exemplo n.º 8
0
        // GET: Techniques
        public IActionResult Index()
        {
            using var context = new SqlLiteContext();
            var techniques = context.Techniques.OrderBy(foo => foo.Name).ToList();

            return(View(techniques));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Create(EmployeeViewModel model)
        {
            if (ModelState.IsValid)
            {
                string   uniqueFileName = UploadedFile(model);
                Employee employee       = new Employee
                {
                    EmployeeName   = model.EmployeeName,
                    EmployeeInfo   = model.EmployeeInfo,
                    EmployeRole    = model.EmployeRole,
                    Interest       = model.Interest,
                    ProfilePicture = uniqueFileName,
                    City           = model.City,
                    Tele           = model.Tele,
                    Linkedin       = model.Linkedin,
                    Mail           = model.Mail
                };

                var context = new SqlLiteContext();
                context.Add(employee);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
Exemplo n.º 10
0
        public ActionResult AdminCourse(int employeeid)
        {
            List <TrainingViewModel> Trainingviewmodellist = new List <TrainingViewModel>();

            List <Training> employeetraininglist = TrainingService.GetByEmployee(employeeid);

            using var context = new SqlLiteContext();
            List <Training> traininglist = context.Trainings.Where(a => a.IsDegree == false).ToList();

            foreach (Training t in traininglist)
            {
                TrainingViewModel tvm = new TrainingViewModel();
                tvm.TrainingId = t.TrainingId;
                tvm.EmployeeId = employeeid;
                tvm.Name       = t.Name;
                tvm.IsDegree   = t.IsDegree;
                foreach (Training te in employeetraininglist)
                {
                    if (t.TrainingId == te.TrainingId)
                    {
                        tvm.Connected = true;
                    }
                }
                Trainingviewmodellist.Add(tvm);
            }
            var sortedlist = Trainingviewmodellist.OrderBy(foo => foo.Name).ToList();
            var arv        = new BindEmployeeTrainingViewModel(sortedlist);

            return(View(arv));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Create([Bind("TrainingId,Name,IsDegree")] Training training)
        {
            if (ModelState.IsValid)
            {
                bool duplicate = false;

                using var context = new SqlLiteContext();
                var trainings = context.Trainings.ToList();
                foreach (var entity in trainings)
                {
                    if (training.Name == entity.Name)
                    {
                        duplicate = true;
                    }
                }
                if (!duplicate)
                {
                    context.Add(training);
                    await context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(RedirectToAction("Duplicate", new { name = training.Name }));
        }
Exemplo n.º 12
0
        public async Task <IActionResult> Create([Bind("ExpertiseId,Name")] Expertise expertise)
        {
            if (ModelState.IsValid)
            {
                bool duplicate = false;

                using var context = new SqlLiteContext();
                var expertises = context.Expertises.ToList();
                foreach (var entity in expertises)
                {
                    if (expertise.Name == entity.Name)
                    {
                        duplicate = true;
                    }
                }
                if (!duplicate)
                {
                    context.Add(expertise);
                    await context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(RedirectToAction("Duplicate", new { name = expertise.Name }));
        }
Exemplo n.º 13
0
        public static List <SearchViewModel> SearchAssignment(string search)
        {
            List <SearchViewModel> searchviewmodels = new List <SearchViewModel>();
            var context = new SqlLiteContext();

            var query = from e in context.Assigments
                        join d in context.Employees on e.Employeeid equals d.EmployeeId
                        where e.Teknik.ToLower().Contains(search.ToLower())
                        select new
            {
                Entity = "Uppdrag",
                Name   = e.Teknik,
                d.EmployeeId,
                d.EmployeeName
            };

            var list = query.ToList();

            foreach (var i in list)
            {
                SearchViewModel svm = new SearchViewModel();
                svm.Entity       = i.Entity;
                svm.Name         = i.Name;
                svm.EmployeeId   = i.EmployeeId;
                svm.EmployeeName = i.EmployeeName;
                svm.IsEmpty      = false;
                searchviewmodels.Add(svm);
            }

            return(searchviewmodels);
        }
Exemplo n.º 14
0
        public async Task <IActionResult> Edit(int id, [Bind("ExpertiseId,Name")] Expertise expertise)
        {
            if (id != expertise.ExpertiseId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    using var context = new SqlLiteContext();
                    context.Update(expertise);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExpertiseExists(expertise.ExpertiseId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(expertise));
        }
Exemplo n.º 15
0
        public static List <SearchViewModel> SearchExpertise(string search)
        {
            List <SearchViewModel> searchviewmodels = new List <SearchViewModel>();
            var context = new SqlLiteContext();

            var query = from e in context.Employees
                        join d in context.EmployeeExpertises on e.EmployeeId equals d.EmployeeId
                        join f in context.Expertises on d.ExpertiseId equals f.ExpertiseId
                        where f.Name.ToLower().Contains(search.ToLower())
                        select new
            {
                Entity = "Expertise",
                f.Name,
                e.EmployeeId,
                e.EmployeeName
            };

            var list = query.ToList();

            foreach (var i in list)
            {
                SearchViewModel svm = new SearchViewModel();
                svm.Entity       = i.Entity;
                svm.Name         = i.Name;
                svm.EmployeeId   = i.EmployeeId;
                svm.EmployeeName = i.EmployeeName;
                svm.IsEmpty      = false;
                searchviewmodels.Add(svm);
            }

            return(searchviewmodels);
        }
Exemplo n.º 16
0
        public async Task <IActionResult> Edit(int id, [Bind("TrainingId,Name,IsDegree")] Training training)
        {
            if (id != training.TrainingId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var context = new SqlLiteContext();
                    context.Update(training);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TrainingExists(training.TrainingId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(training));
        }
        public ActionResult Admin(int employeeid)
        {
            List <ExpertiseViewModel> Expertiseviewmodellist = new List <ExpertiseViewModel>();
            List <Expertise>          employeeexpertiselist  = ExpertiseService.GetByEmployee(employeeid);

            using var context = new SqlLiteContext();
            List <Expertise> expertiselist = context.Expertises.ToList();

            foreach (Expertise t in expertiselist)
            {
                ExpertiseViewModel evm = new ExpertiseViewModel();
                evm.ExpertiseId = t.ExpertiseId;
                evm.EmployeeId  = employeeid;
                evm.Name        = t.Name;
                foreach (Expertise te in employeeexpertiselist)
                {
                    if (t.ExpertiseId == te.ExpertiseId)
                    {
                        evm.Connected = true;
                    }
                }
                Expertiseviewmodellist.Add(evm);
            }
            var sortedlist = Expertiseviewmodellist.OrderBy(foo => foo.Name).ToList();
            var arv        = new BindEmployeeExpertiseViewModel(sortedlist);

            return(View(arv));
        }
Exemplo n.º 18
0
        public static Employee Get(int employeeid)
        {
            using var context = new SqlLiteContext();
            var employee = context.Employees.SingleOrDefault(a => a.EmployeeId == employeeid);

            return(employee);
        }
Exemplo n.º 19
0
        public static List <Assigment> GetEvery()
        {
            using var context = new SqlLiteContext();
            var assignments = context.Assigments.ToList();

            return(assignments);
        }
Exemplo n.º 20
0
        public static Technique Get(int techid)
        {
            using var context = new SqlLiteContext();
            var tech = context.Techniques.Single(a => a.TechniqueId == techid);

            return(tech);
        }
Exemplo n.º 21
0
        public async Task <IActionResult> Edit(int id, [Bind("CompanyId,CompanyName,ProfileCompanyAdress,ProfileCompanyPostalAdress,City")] Company company)
        {
            if (id != company.CompanyId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    using var context = new SqlLiteContext();
                    context.Update(company);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompanyExists(company.CompanyId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(company));
        }
Exemplo n.º 22
0
        public ActionResult Admin(int employeeid)
        {
            List <TradeViewModel> Tradeviewmodellist = new List <TradeViewModel>();
            List <Trade>          employeetradelist  = TradeService.GetByEmployee(employeeid);

            using var context = new SqlLiteContext();
            List <Trade> tradelist = context.Trades.ToList();

            foreach (Trade t in tradelist)
            {
                TradeViewModel tvm = new TradeViewModel();
                tvm.TradeId    = t.TradeId;
                tvm.EmployeeId = employeeid;
                tvm.Name       = t.Name;
                tvm.Connected  = false;
                foreach (Trade te in employeetradelist)
                {
                    if (t.TradeId == te.TradeId)
                    {
                        tvm.Connected = true;
                    }
                }
                Tradeviewmodellist.Add(tvm);
            }
            var sortedlist = Tradeviewmodellist.OrderBy(foo => foo.Name).ToList();
            var model      = new BindEmployeeTradeViewModel(sortedlist);

            return(View(model));
        }
Exemplo n.º 23
0
        public static void Update(Employee employee)
        {
            using var context = new SqlLiteContext();
            var entity = context.Employees.Update(employee);

            entity.State = EntityState.Modified;

            context.SaveChanges();
        }
Exemplo n.º 24
0
        public SqlLiteRepository(SqlLiteContext context)
        {
            _context = context;

            Images    = new TableWrapper <Image>(context, c => c.Images);
            Ratings   = new TableWrapper <Rating>(context, c => c.Ratings);
            Tags      = new TableWrapper <Tag>(context, c => c.Tags);
            ImageTags = new TableWrapper <ImageTag>(context, c => c.ImageTags);
        }
Exemplo n.º 25
0
        public static void UpdateCourseByEmployee(Training training)
        {
            using var context = new SqlLiteContext();
            var entity = context.Trainings.Update(training);

            entity.State = EntityState.Modified;

            context.SaveChanges();
        }
Exemplo n.º 26
0
        public static void Update(Assigment assigment)
        {
            using var context = new SqlLiteContext();
            var entity = context.Assigments.Update(assigment);

            entity.State = EntityState.Modified;

            context.SaveChanges();
        }
Exemplo n.º 27
0
        public static void Delete(Assigment assigment)
        {
            using var context = new SqlLiteContext();
            var entity = context.Assigments.Remove(assigment);

            entity.State = EntityState.Deleted;

            context.SaveChanges();
        }
Exemplo n.º 28
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            using var context = new SqlLiteContext();
            var expertise = await context.Expertises.FindAsync(id);

            context.Expertises.Remove(expertise);
            await context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 29
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var context   = new SqlLiteContext();
            var assigment = await context.Assigments.FindAsync(id);

            context.Assigments.Remove(assigment);
            await context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 30
0
        public static void Add(Employee employee)
        {
            using (var context = new SqlLiteContext())
            {
                var entity = context.Employees.Add(employee);
                entity.State = EntityState.Added;

                context.SaveChanges();
            }
        }