public bool AddOutsourcingCompany(HiringCompanyData.OutsourcingCompany oCompany)
        {
            using (var access = new AccessDB())
            {
                HiringCompanyData.OutsourcingCompany oc = access.OcActions.FirstOrDefault(f => f.Name.Equals(oCompany.Name));
                if (oc == null)
                {
                    access.OcActions.Add(oCompany);

                    int i = access.SaveChanges();

                    if (i > 0)
                    {
                        Log.Info("Successfully added outsourcing company into DB");
                        return(true);
                    }
                    return(false);
                }
                else
                {
                    Log.Warn("Outsourcing company already exists in DB");
                    return(false);
                }
            }
        }
        public int GetHcIdForUser(string username)
        {
            using (var access = new AccessDB())
            {
                Log.Info("Successfully returned company id for employee username.");
                var employee = access.Actions.Include(x => x.HiringCompanyId).FirstOrDefault(f => f.Username.Equals(username));

                return(employee.HiringCompanyId.IDHc);
            }
        }
        /// <summary>
        ///     Method returns instance of Employee only if username and password maches
        ///     return null if it doesnt
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public Employee GetEmployee(string username, string password)
        {
            Log.Debug("Enter GetEmployee method.");
            using (var access = new AccessDB())
            {
                Employee employee = access.Actions.FirstOrDefault(f => f.Username.Equals(username) && f.Password.Equals(password));

                Log.Info("Successfully returned employee");
                return(employee);
            }
        }
        public List <Employee> GetReallyEmployees()
        {
            Log.Debug("Enter GetReallyEmployees method.");
            using (var access = new AccessDB())
            {
                List <Employee> employees = new List <Employee>(20);

                foreach (var em in access.Actions)
                {
                    employees.Add(em);
                }
                Log.Info("Successfully returned list of employees");
                return(employees);
            }
        }
        public List <Project> GetProjects()
        {
            Log.Debug("Enter GetProjects method.");
            using (var access = new AccessDB())
            {
                List <Project> ret = new List <Project>();
                foreach (var pr in access.PrActions)
                {
                    ret.Add(pr);
                }

                Log.Info("Successfully returned list of projects.");
                return(ret);
            }
        }
        public List <Project> GetPartnershipProjects(int hiringCompanyTr)
        {
            using (var access = new AccessDB())
            {
                List <Project> ret = new List <Project>();

                List <OutsourcingCompany> oc = new List <OutsourcingCompany>();
                oc = GetPartnerOc(hiringCompanyTr);
                var allProjectList = access.PrActions.Include(x => x.Company);

                //List<Project> projects = allProjectList as List<Project>;

                //foreach (var ocItem in allProjectList)
                //{
                foreach (var o in oc)
                {
                    //var project = access.PrActions.Include(x => x.Company).FirstOrDefault(f => f.Company.Id.Equals(o.Id));
                    foreach (Project pr in allProjectList)
                    {
                        if (pr.Company != null)
                        {
                            if (pr.Company.Id.Equals(o.Id))
                            {
                                Project p = new Project();
                                p.Name         = pr.Name;
                                p.Id           = pr.Id;
                                p.ProjectState = pr.ProjectState;
                                p.Description  = pr.Description;

                                ret.Add(p);
                            }
                        }
                    }
                }

                if (ret.Count == 0)
                {
                    Log.Warn("No project to return");
                }
                else
                {
                    Log.Info("Successfully returned project");
                }

                return(ret);
            }
        }
        public HiringCompany GetHiringCompanyFromThr(int hiringCompanyThr)
        {
            Log.Debug("Enter GetCompany method.");
            using (var acces = new AccessDB())
            {
                HiringCompany cm = acces.HcActions.FirstOrDefault(f => f.CompanyIdThr == hiringCompanyThr);

                if (cm != null)
                {
                    Log.Info("Successfully returned hiring company data.");
                }
                else
                {
                    Log.Warn("Company with thad id doesn't exists in DB");
                }
                return(cm);
            }
        }
Exemple #8
0
        public List <UserStory> GetUserStory(string projectName)
        {
            using (var access = new AccessDB())
            {
                List <UserStory> ret = new List <UserStory>();

                foreach (UserStory us in access.UsAction)
                {
                    if (us.Project.Name.Equals(projectName))
                    {
                        ret.Add(us);
                    }
                }

                Log.Info("Successfully returned user stories for specified project name.");
                return(ret);
            }
        }
Exemple #9
0
        public UserStory GetUserStoryFromId(int id)
        {
            using (var access = new AccessDB())
            {
                UserStory us = access.UsAction.FirstOrDefault(f => f.Id == id);

                if (us != null)
                {
                    Log.Info("Successfully returned user story for specified id.");
                }
                else
                {
                    Log.Warn("User story for specified id doesn't exist.");
                }

                return(us);
            }
        }
        public List <Employee> GetAllNotSignedInEmployees()
        {
            Log.Debug("Enter GetAllNotSignedInEmployees method.");
            using (var access = new AccessDB())
            {
                List <Employee> employees = new List <Employee>(20);

                foreach (var em in access.Actions)
                {
                    if (!em.Login)
                    {
                        employees.Add(em);
                    }
                }
                Log.Info("Successfully returned not signedIn employees");
                return(employees);
            }
        }
        public Project GetProject(string name)
        {
            using (var access = new AccessDB())
            {
                Project p = access.PrActions.FirstOrDefault(f => f.Name.Equals(name));

                if (p == null)
                {
                    Log.Warn("Project with specified name doesn't exist in DB.");
                }
                else
                {
                    Log.Info("Successfully returned project from DB.");
                }

                return(p);
            }
        }
        public OutsourcingCompany GetOutsourcingCompany(string name)
        {
            using (var access = new AccessDB())
            {
                HiringCompanyData.OutsourcingCompany oc = access.OcActions.FirstOrDefault(f => f.Name.Equals(name));

                if (oc == null)
                {
                    Log.Warn("Requestet Outsourcing company doesn't exists in DB.");
                }
                else
                {
                    Log.Info("Successfully returned Outsourcing company with specified name.");
                }

                return(oc);
            }
        }
        public String GetEmployeeEmail(string username)
        {
            Log.Debug("Enter GetEmployeeEmail method.");
            using (var access = new AccessDB())
            {
                Employee emp = access.Actions.FirstOrDefault(f => f.Username.Equals(username));

                if (emp != null)
                {
                    Log.Info("Successfully returned employee email");
                    return(emp.Email);
                }
                else
                {
                    Log.Warn("Employee with that username does not exist. Failed to retrieve email.");
                    return(string.Empty);
                }
            }
        }
        public bool UpdateEmployee(Employee employee)
        {
            Log.Debug("Enter UpdateEmployee method.");
            using (var access = new AccessDB())
            {
                //access.Actions.Attach(employee);
                Employee em = access.Actions.FirstOrDefault(f => f.Email.Equals(employee.Email));
                if (em != null)
                {
                    Log.Debug("Employee exists");
                    em.Email               = employee.Email;
                    em.EndTime             = employee.EndTime;
                    em.HiringCompanyId     = employee.HiringCompanyId;
                    em.Login               = employee.Login;
                    em.Name                = employee.Name;
                    em.Password            = employee.Password;
                    em.PasswordUpadateDate = employee.PasswordUpadateDate;
                    em.Position            = employee.Position;
                    em.StartTime           = employee.StartTime;
                    em.Surname             = employee.Surname;
                    em.Username            = employee.Username;



                    //access.Entry(employee).State = System.Data.Entity.EntityState.Modified;

                    int i = access.SaveChanges();

                    if (i > 0)
                    {
                        Log.Info("Successfully updated DB");
                        return(true);
                    }
                    Log.Warn("Failed to update DB");
                    return(false);
                }
                else
                {
                    Log.Warn("Employee with that username does not exist. Failed updating employee.");
                    return(false);
                }
            }
        }
        public bool SetOcToProject(string projectName, int outsourcingCompanyId)
        {
            using (var access = new AccessDB())
            {
                Project p = access.PrActions.FirstOrDefault(f => f.Name.Equals(projectName));

                if (p != null)
                {
                    OutsourcingCompany oc = access.OcActions.FirstOrDefault(f => f.IdFromOutSourcingDB == outsourcingCompanyId);

                    if (oc != null)
                    {
                        p.Company = oc;
                        access.OcActions.Attach(p.Company);
                    }
                    else
                    {
                        Log.Warn("Outsourcing company doesn't exists.");
                    }

                    int i = access.SaveChanges();

                    if (i > 0)
                    {
                        Log.Info("Successfully assigned project to Outsourcing company.");
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    Log.Warn("Project doesn't exists.");
                    return(false);
                }
            }
        }
        public List <OutsourcingCompany> GetOutsourcingCompanies()
        {
            using (var access = new AccessDB())
            {
                List <OutsourcingCompany> ret = new List <OutsourcingCompany>();

                foreach (var oc in access.OcActions)
                {
                    ret.Add(oc);
                }

                if (ret != null)
                {
                    Log.Info("Successfully returned list of outsourcing companies.");
                }
                else
                {
                    Log.Warn("No outsourcing company to show.");
                }


                return(ret);
            }
        }