private void btnInsert_Click(object sender, EventArgs e)
        {
            EmployeesRepository employees = new EmployeesRepository();

            try
            {
                employees.Insert(
                    new SqlParameter("FirstName", txtFirstname.Text)
                {
                    SqlDbType = SqlDbType.NVarChar
                },
                    new SqlParameter("LastName", txtLastname.Text)
                {
                    SqlDbType = SqlDbType.NVarChar
                },
                    new SqlParameter("Phone", txtPhone.Text)
                {
                    SqlDbType = SqlDbType.NVarChar
                }
                    );
                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        public HolidayTests(ITestOutputHelper output)
        {
            _output = output;
            var setup = new SetUp();

            setup.Initialize();
            _context = setup.HolidayDbContext;
            var mapper      = setup.Mapper;
            var userManager = setup.InitializeUserManager();

            _holidaysCount = setup.GetCount("holidays");
            _configuration = setup.GetConfiguration();
            _timeService   = new TimeService();
            var mockUserService     = new Mock <IUserService>().Object;
            var mockOvertimeUtility = new Mock <IOvertimeUtility>().Object;

            _holidaysRepository  = new HolidaysRepository(_context);
            _employeesRepository = new EmployeesRepository(_context, userManager);
            _clientsRepository   = new ClientsRepository(_context);
            var holidayGuidsRepository          = new HolidayGuidsRepository(_context);
            var mockNotificationSettingsService = new Mock <INotificationSettingsService>().Object;

            _employeesService = new EmployeesService(_employeesRepository, mapper, mockOvertimeUtility, _timeService,
                                                     mockUserService, mockNotificationSettingsService, _configuration);
            _holidaysService = new HolidaysService(_holidaysRepository, _employeesRepository, mapper, _timeService,
                                                   mockOvertimeUtility, _clientsRepository, mockUserService, _configuration, holidayGuidsRepository);
        }
Esempio n. 3
0
        protected void gvUsers_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "view")
            {
                int         index  = Convert.ToInt32(e.CommandArgument);
                GridViewRow row    = gvUsers.Rows[index];
                int         userid = row.Cells[0].Text.ToInt();
                Session.Add("useridForAdminDetails", userid);

                if (userid % 2 == 0)
                {
                    //karmand
                    setEmpRegSeenTrue(userid);
                    Response.Redirect("/Admin/ManageUsers/EmployeeInfo");
                }
                else
                {
                    setUserRegSeenTrue(userid);
                    Response.Redirect("/Admin/ManageUsers/UserInfo");
                }
            }
            if (e.CommandName == "delet")
            {
                int         index  = Convert.ToInt32(e.CommandArgument);
                GridViewRow row    = gvUsers.Rows[index];
                int         userid = row.Cells[0].Text.ToInt();
                Session.Add("useridForAdminDetails", userid);

                if (userid % 2 == 0)
                {
                    //karmandep.DeleteEmployee(userid)ur.DeleteUser(userid)
                    EmployeesRepository ep = new EmployeesRepository();
                    if (ep.DeleteEmployee(userid))
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('حذف انجام شد')", true);//لینک بشه
                        fillGV();
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('مشکلی پیش آمد ، لطفا دوباره امتحان کنید اگر حل نشد با پشتیبانی تماس بگیرید ');", true);
                    }
                    //Response.Redirect("/Admin/ManageUsers/EmployeeInfo");
                }
                else
                {
                    UsersRepository ur = new UsersRepository();

                    if (ur.DeleteUser(userid))
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('حذف انجام شد')", true);//لینک بشه
                        fillGV();
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('مشکلی پیش آمد ، لطفا دوباره امتحان کنید اگر حل نشد با پشتیبانی تماس بگیرید ');", true);
                    }
                    // Response.Redirect("/Admin/ManageUsers/UserInfo");
                }
            }
        }
Esempio n. 4
0
        public void Test_GetHowLongHireDate()
        {
            var repository = new EmployeesRepository();
            var employee   = repository.GetHowLongHireDate(connection);

            Assert.IsTrue(employee.Count() >= 0);
        }
Esempio n. 5
0
        public async void AddAsync_ShouldAddEmployee()
        {
            // Arrange
            var employeeToAdd = new Employee {
                Id = 1, FirstName = "John", LastName = "Dou", MediaInteractivaEmployee = true
            };

            var options = new DbContextOptionsBuilder <AppContext>()
                          .UseInMemoryDatabase(databaseName: "Employees3")
                          .Options;

            using (var appContext = new AppContext(options))
            {
                var repo = new EmployeesRepository(appContext);

                // Act
                await repo.AddAsync(employeeToAdd);


                // Assert
                var employee = appContext.Employees.Find(employeeToAdd.Id);
                Assert.Equal(employeeToAdd.Id, employee.Id);
                Assert.Equal(employeeToAdd.FirstName, employee.FirstName);
                Assert.Equal(employeeToAdd.LastName, employee.LastName);
                Assert.Equal(employeeToAdd.MediaInteractivaEmployee, employee.MediaInteractivaEmployee);
            }
        }
Esempio n. 6
0
        public async void DeleteAsync_ShouldDeleteEmployee()
        {
            // Arrange
            var employeeToDelete = new Employee {
                Id = 1, FirstName = "John", LastName = "Dou", MediaInteractivaEmployee = true
            };

            var options = new DbContextOptionsBuilder <AppContext>()
                          .UseInMemoryDatabase(databaseName: "Employees5")
                          .Options;

            using (var appContext = new AppContext(options))
            {
                await appContext.Employees.AddAsync(employeeToDelete);

                await appContext.SaveChangesAsync();
            }

            using (var appContext = new AppContext(options))
            {
                var repo = new EmployeesRepository(appContext);

                // Act
                await repo.DeleteAsync(employeeToDelete.Id);


                // Assert
                var employee = appContext.Employees.Find(employeeToDelete.Id);
                Assert.Null(employee);
            }
        }
        public TimesheetsController(ILogger <TimesheetsController> logger)
        {
            timesheetRepository = new TimesheetsRepository();
            employeeRepository  = new EmployeesRepository();

            this.logger = logger;
        }
Esempio n. 8
0
        public void Test_GetAll_Employee()
        {
            var repository = new EmployeesRepository();
            var employee   = repository.GetAll();

            Assert.IsTrue(employee.Count() == 0);
        }
Esempio n. 9
0
        public HttpResponseMessage Delete(Employee e)
        {
            var employee = EmployeesRepository.DeleteEmployee(e);
            HttpResponseMessage responce = Request.CreateResponse(HttpStatusCode.OK, employee);

            return(responce);
        }
Esempio n. 10
0
        public HttpResponseMessage Edit(EmployeesDto employee, int id)
        {
            var repository = new EmployeesRepository();
            var result     = repository.Edit(employee, id);

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Esempio n. 11
0
        public HttpResponseMessage Get(int id)
        {
            var employees = EmployeesRepository.GetEmployee(id);
            HttpResponseMessage responce = Request.CreateResponse(HttpStatusCode.OK, employees);

            return(responce);
        }
Esempio n. 12
0
        public void Test_FindByID_Employee()
        {
            var repository = new EmployeesRepository();
            var employee   = repository.FindById(1, connection);

            Assert.IsNotNull(employee);
        }
Esempio n. 13
0
        public ActionResult Edit(EditVM model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            EmployeesRepository repo = new EmployeesRepository();

            Employee item = new Employee();

            item.Id        = model.Id;
            item.Username  = model.Username;
            item.Password  = model.Password;
            item.FirstName = model.FirstName;
            item.LastName  = model.LastName;
            item.Phone     = model.Phone;
            item.Email     = model.Email;

            if (item.Id > 0)
            {
                repo.Update(item);
            }
            else
            {
                repo.Insert(item);
            }

            return(RedirectToAction("Index", "Employees"));
        }
Esempio n. 14
0
        public HttpResponseMessage Get()
        {
            var employees = EmployeesRepository.GetAllEmployees();
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employees);

            return(response);
        }
Esempio n. 15
0
        public HttpResponseMessage Put(Employee e)
        {
            var employees = EmployeesRepository.UpdateEmployee(e);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employees);

            return(response);
        }
Esempio n. 16
0
        public FileStreamResult ExportProtocol(Guid id)
        {
            StiReport report    = new StiReport();
            var       model     = new DrugAnaliticRepository().GetExpExpertiseStageDosage(id);
            var       applicant = new EmployeesRepository().GetById(model.EXP_ExpertiseStage.EXP_DrugDeclaration.OwnerId);


            report.Load(Server.MapPath("../Reports/DrugDeclaration/AnaliseProtocol.mrt"));
            foreach (var data in report.Dictionary.Databases.Items.OfType <StiSqlDatabase>())
            {
                data.ConnectionString = UserHelper.GetCnString();
            }

            if (report.Dictionary.Variables.Contains("DosageStageId"))
            {
                report.Dictionary.Variables["DosageStageId"].ValueObject = id;
            }
            if (report.Dictionary.Variables.Contains("ApplicationName"))
            {
                report.Dictionary.Variables["ApplicationName"].ValueObject = applicant.DisplayName;
            }
            report.Render(false);
            var stream = new MemoryStream();

            report.ExportDocument(StiExportFormat.Pdf, stream);
            stream.Position = 0;
            var reportname = "Протокол_" + DateTime.Now.ToString("yyyy-mm-dd hh.mm.ss") + ".pdf";

            return(File(stream, "application/pdf", reportname));
        }
Esempio n. 17
0
        public void EmployeesRepositoryTests_GetByAccount()
        {
            EmployeesRepository repository = new EmployeesRepository();
            var result = repository.GetByEmployeesAccount("Jackson");

            Assert.IsTrue(result.Name == "傑克森");
        }
Esempio n. 18
0
        public void EmployeesRepositoryTests_GetAll()
        {
            EmployeesRepository repository = new EmployeesRepository();
            var result = repository.GetAll();

            Assert.IsTrue(result.Count() == 3);
        }
Esempio n. 19
0
        private async Task <EmployeeEntity> GetEmployee(string id)
        {
            EmployeesRepository repo = new EmployeesRepository();
            var emp = await repo.GetEmployeeById(id);

            return(emp);
        }
Esempio n. 20
0
        public HttpResponseMessage GetList()
        {
            var repository = new EmployeesRepository();
            var result     = repository.ListAllEmployees();

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Esempio n. 21
0
        private void setLabels()
        {
            EmployeesRepository er = new EmployeesRepository();
            DataTable           dt = er.getEmployeeProfileInfo(empid);

            lblfirstName.Value  = dt.Rows[0][1].ToString();
            lblLastName.Value   = dt.Rows[0][2].ToString();
            hFullName.InnerText = dt.Rows[0][1].ToString() + " " + dt.Rows[0][2].ToString();
            lblid.Value         = dt.Rows[0][0].ToString();
            lbladdress.Value    = dt.Rows[0][8].ToString();

            lblemail.Value         = dt.Rows[0][10].ToString();
            ddlState.SelectedIndex = (dt.Rows[0][6].ToString().ToInt() - 1);

            string asd = dt.Rows[0][7].ToString();

            ddlCity.SelectedValue = asd;
            lblmobile.Value       = dt.Rows[0][9].ToString();
            lblusername.Value     = dt.Rows[0][3].ToString();
            password.Value        = dt.Rows[0][4].ToString();
            lblzip.Value          = dt.Rows[0][11].ToString();

            if (dt.Rows[0][12] != DBNull.Value)
            {
                Image1.Src = dt.Rows[0][12].ToString();
            }
        }
Esempio n. 22
0
        public void Employees_Create()
        {
            var repository = new EmployeesRepository();
            //Employees employee = new Employees()
            //{
            //    Name = "洪識超",
            //    Phone = "0123456789",
            //    HireDate = new DateTime(1996, 06, 01),
            //};
            //repository.Create(employee);
            //Employees employee1 = new Employees()
            //{
            //    Name = "簡愷祐",
            //    Phone = "0123456789",
            //    HireDate = new DateTime(1996, 01, 29),
            //};
            //repository.Create(employee1);
            //Employees employee2 = new Employees()
            //{
            //    Name = "黃思源",
            //    Phone = "0123456789",
            //    HireDate = new DateTime(1996, 02, 16),
            //};
            //repository.Create(employee2);
            var employees = repository.GetAll(connection);

            Assert.IsTrue(employees.Count() > 0);
        }
Esempio n. 23
0
        public HttpResponseMessage GetAllTrainingByEmployeedId(int id)
        {
            var repo   = new EmployeesRepository();
            var result = repo.GetAllTrainingByEmployeeId(id);

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Esempio n. 24
0
        public void Test_FindByHireYear()
        {
            var repository = new EmployeesRepository();
            var employee   = repository.FindByHireYear(1900, 2000);

            Assert.IsTrue(employee.Count() >= 0);
        }
        static void Main()
        {
            //IChildRepository childRepo = new ChildRepository();
            //IChallengeRepository challengeRepo = new ChallengeRepository();
            //childRepo.Save(new Child("Alin", 10));
            //childRepo.Save(new Child("Andrei", 12));
            //childRepo.Delete(2);

            /*foreach(var element in childRepo.FindAll())
             * {
             * Trace.WriteLine(element);
             * }*/

            IChildRepository     childRepo     = new ChildRepository();
            IChallengeRepository challengeRepo = new ChallengeRepository();
            IEmployeesRepository employeesRepo = new EmployeesRepository();
            IEntriesRepository   entriesRepo   = new EntriesRepository(childRepo, challengeRepo);

            Service service = new Service(childRepo, challengeRepo, employeesRepo, entriesRepo);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Login(service));
        }
Esempio n. 26
0
        private void bestEmploees()
        {
            string text = "";
            EmployeesRepository       er = new EmployeesRepository();
            EmployeeProjectRepository ep = new EmployeeProjectRepository();
            DataTable dt = er.getTopEmploees();

            if (dt.Rows.Count != 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string fullName     = dt.Rows[i][0].ToString();
                    string score        = dt.Rows[i][1].ToString();
                    int    id           = dt.Rows[i][2].ToString().ToInt();
                    string projectCount = ep.getEmployeeProjectCount(id).ToString();
                    string img          = er.getEmployeeByID(id).empImage;

                    text += "<div class='item '><div class='theBest '><div class='imgDiv'><img class='empImg' src='";
                    text += img;
                    text += "'/></div ><div class='employeeName'><h3>";
                    text += "";
                    text += fullName;
                    string txt = ResolveUrl("images/testimonial/down-arrow.png");
                    text += "</h3></div><div class='arrow row m0'><img src='" + txt + "'/></div><div class='projectNum'><h4>";
                    text += " تعداد پروژه ها";
                    text += "</h4><h3>";
                    text += projectCount;
                    text += "</h3></div><div class='EmployeeScore'><h4>";
                    text += "امتیاز</h4><h3>";
                    text += score;
                    text += "</h3></div></div></div>";
                }
                best.InnerHtml = text;
            }
        }
Esempio n. 27
0
        public void Test_FindByName()
        {
            var repository = new EmployeesRepository();
            var product    = repository.FindByName("abc");

            Assert.IsNull(product);
        }
Esempio n. 28
0
        public List <EmployeesEntity> SelectAllEmployees()
        {
            var returnedEntities = new List <EmployeesEntity>();

            try
            {
                using (var repository = new EmployeesRepository())
                {
                    foreach (var entity in repository.SelectAll())
                    {
                        entity.NetSalary = GetNetSalary(entity.GrossSalary, entity.Age);
                        returnedEntities.Add(entity);
                    }
                }

                return(returnedEntities);
            }
            catch (Exception ex)
            {
                //Log exception error
                _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true);

                throw new Exception("BusinessLogic:EmployeesBusiness::SelectAllEmployees::Error occured.", ex);
            }
        }
Esempio n. 29
0
        public HttpResponseMessage Get(string name)
        {
            var employees = EmployeesRepository.SearchEmployeeByName(name);
            HttpResponseMessage responce = Request.CreateResponse(HttpStatusCode.OK, employees);

            return(responce);
        }
Esempio n. 30
0
        public HttpResponseMessage GetEmployee(int id)
        {
            var repository = new EmployeesRepository();
            var result     = repository.GetEmployeeById(id);

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
        public void FindByFilter_FilterString_ListOfEmployees()
        {
            IList<Employee> employee;
            string lastNameFilter = "Aleksandr";

            using (var dbContext = new DatabaseContext(testUser, testPass))
            {
                var repository = new EmployeesRepository(dbContext);
                employee = repository.FindByLastName(lastNameFilter);
            }

            Assert.IsTrue(employee.All(x => x.LastName.Contains(lastNameFilter)));
        }
Esempio n. 32
0
        public EmployeeDto Authenticate(string email, string password)
        {
            var repo = new EmployeesRepository();
            EmployeeDto returnedEmployee = repo.Authenticate(email);

            if (returnedEmployee != null)
            {
                if (returnedEmployee.Password == password)
                {
                    return returnedEmployee;
                }
            }

            return null;
        }
        public JsonResult Create(BonusDto bonusDto)
        {
            BonusAggregate bonus;

            if (bonusDto.Amount <= 0)
                throw new ArgumentOutOfRangeException("Amount should be more than 0");

            if (bonusDto.EmployeeId <= 0)
                throw new ArgumentNullException("You should specify an existing employee");

            using (var dbContext = new DatabaseContext())
            {
                BonusesRepository = new BonusesRepository(dbContext);
                var employeeRepository = new EmployeesRepository(dbContext);
                bonus = new BonusFactory(employeeRepository).Create(bonusDto);

                BonusesRepository.Save(bonus);
            }

            return Json(bonus);
        }
        public JsonResult Edit(BonusDto bonusDto)
        {
            if (bonusDto == null)
                throw new ArgumentNullException("bonusDto can not be null in controller Edit");

            Employee employee = null;
            BonusAggregate bonus = null;
            using (var dbContext = new DatabaseContext())
            {
                if (bonusDto.EmployeeId != 0)
                {
                    var employeeRepository = new EmployeesRepository(dbContext);
                    employee = employeeRepository.GetById(bonusDto.EmployeeId);
                }

                BonusesRepository = new BonusesRepository(dbContext);
                bonus = BonusesRepository.GetById(bonusDto.BonusId);
                bonus.Comment = bonusDto.Comment;
                bonus.Amount = bonusDto.Amount;
                bonus.Date = bonusDto.Date;
                bonus.IsActive = bonusDto.IsActive;

                if (employee != null &&
                    employee.EmployeeId != bonus.EmployeeId)
                {
                    bonus.Employee = employee;
                }

                BonusesRepository.Save(bonus);
            }

            return Json(bonus);
        }
Esempio n. 35
0
 public static EmployeesRepository GetEmployeesRepository(IUnitOfWork unitOfWork)
 {
     var repository = new EmployeesRepository();
     repository.UnitOfWork = unitOfWork;
     return repository;
 }
        public void GetEmployees_ListOfIds_ListOfEmployees()
        {
            IList<Employee> employee;

            using (var dbContext = new DatabaseContext(testUser, testPass))
            {
                var repository = new EmployeesRepository(dbContext);
                var ids = new int[5] { 1, 2, 3, 4, 5 };
                employee = repository.GetByIdList(ids);
            }

            Assert.IsTrue(employee.Count > 1);
        }
Esempio n. 37
0
        public DataAccessTests()
        {
            _repository = new EmployeesRepository();

            _employee = CreateDummyEmployee();
        }
Esempio n. 38
0
 public EmployeesService()
 {
     _repo = new EmployeesRepository();
 }
Esempio n. 39
0
 public static EmployeesRepository GetEmployeesRepository()
 {
     var repository = new EmployeesRepository();
     repository.UnitOfWork = GetUnitOfWork();
     return repository;
 }
        public JsonResult GetJsonEmployeesByLastName()
        {
            IList<Employee> employees = new List<Employee>();
            string lastName = FilterStringFactory.FormFilterValue(Request.Params);

            if (String.IsNullOrEmpty(lastName) == false)
            {
                using (var dbContext = new DatabaseContext())
                {
                    var employeesRepository = new EmployeesRepository(dbContext);
                    employees = employeesRepository.FindByLastName(lastName);
                }
            }

            if (employees.Count == 0)                    // this's because some magic happens with autocomplete combobox
                employees.Add(new Employee("", "", "")); // and it start to cycle ajax requests if the list is empty or null

            return Json(employees, JsonRequestBehavior.AllowGet);
        }