コード例 #1
0
        public void EditCompany_NameIsNullOrWhiteSpace()
        {
            // Arrange
            var id       = 1;
            var repo     = new CompanyRepo(null);
            var company1 = new Company()
            {
                Id = id, Name = ""
            };
            var company2 = new Company()
            {
                Id = id, Name = " "
            };
            var company3 = new Company()
            {
                Id = id, Name = null
            };

            // Act
            var result1 = repo.EditCompany(id, company1);
            var result2 = repo.EditCompany(id, company2);
            var result3 = repo.EditCompany(id, company3);

            // Assert
            Assert.False(result1);
            Assert.False(result2);
            Assert.False(result3);
        }
コード例 #2
0
        public ActionResult Details(FASViewModel vm)
        {
            if (vm.SelectedCompanies == null)
            {
                vm.SelectedCompanies = new List <string>();
            }
            if (vm.SelectedRegions == null)
            {
                vm.SelectedRegions = new List <string>();
            }
            if (vm.SelectedTerritories == null)
            {
                vm.SelectedTerritories = new List <string>();
            }
            if (vm.SelectedZones == null)
            {
                vm.SelectedZones = new List <string>();
            }
            vm.Companies   = CompanyRepo.GetCompanies(user.UserID);
            vm.Regions     = FASRepo.GetRegions(1, vm.SelectedCompanies.Select(x => x.ToString()).ToList(), user.UserID);
            vm.Zones       = FASRepo.GetZones(1, vm.SelectedCompanies.Select(x => x.ToString()).ToList(), vm.SelectedRegions.Select(x => x.ToString()).ToList(), user.UserID);
            vm.Territories = FASRepo.GeTerritories(1, vm.Companies.Select(x => x.Compcode.ToString()).ToList(), vm.SelectedRegions.Select(x => x.ToString()).ToList(), vm.SelectedZones.Select(x => x.ToString()).ToList(), user.UserID);

            ViewBag.WhereClause = FASRepo.GetWhereClause(vm, "FAS", 1, user.UserID);

            var list = FASRepo.GetDetails("FAS", FASRepo.GetWhereClause(vm, "FAS", 1, user.UserID), user.UserID);

            ViewBag.ListDetails = list;
            return(View(vm));
        }
コード例 #3
0
 public List <ProjectDto> GetAllByName(string name)
 {
     using (CompanyRepo repo = new CompanyRepo())
     {
         var projects = repo.ProjectRepository.GetAllByName(projectName => projectName.Name == name);
         return(projects.Select(project => new ProjectDto
         {
             Id = project.Id,
             Name = project.Name,
             Description = project.Description,
             Created = project.Created,
             Client = project.Client,
             Price = project.Price,
             managerDto = new ManagerDto
             {
                 Id = project.Manager_Id,
                 FirstName = project.manager.FirstName,
                 LastName = project.manager.LastName,
                 PhoneNumber = project.manager.PhoneNumber,
                 Email = project.manager.Email,
                 BirthDate = project.manager.BirthDate,
                 Nationality = project.manager.Nationality,
                 Salary = project.manager.Salary
             }
         }).ToList());
     }
 }
コード例 #4
0
 public ActionResult Edit(CompanyViewModel model)
 {
     if (ModelState.IsValid)
     {
         model.Update_By = User.Identity.Name;
         ResultResponse result = CompanyRepo.Update(model);
         return(Json(new
         {
             success = result.Success,
             entity = model,
             message = result.Message
         }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         ResultResponse result = new ResultResponse();
         result.Success = false;
         result.Message = "Theres blank column, Please fill data correctly !";
         return(Json(new
         {
             success = result.Success,
             entity = model,
             message = result.Message
         }, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #5
0
        public EmployeeDto GetById(int id)
        {
            EmployeeDto employeeDto = new EmployeeDto();

            using (CompanyRepo repo = new CompanyRepo())
            {
                Employee employee = repo.EmployeeRepository.GetByID(id);
                if (employee != null)
                {
                    employeeDto = new EmployeeDto
                    {
                        Id          = employee.Id,
                        FirstName   = employee.FirstName,
                        LastName    = employee.LastName,
                        PhoneNumber = employee.PhoneNumber,
                        Email       = employee.Email,
                        BirthDate   = employee.BirthDate,
                        Position    = employee.Position,
                        Salary      = employee.Salary
                    };
                }
            }

            return(employeeDto);
        }
コード例 #6
0
        protected void login_click(object sender, EventArgs e)
        {
            string email = txt_email_login.Text;

            if ((!string.IsNullOrWhiteSpace(email)))
            {
                CompanyRepo CompanyRepo = new CompanyRepo();
                string      result      = CompanyRepo.forgotPassword(email);
                if (result.Equals("true"))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Password sent to your email address.');", true);
                    return;
                }

                if (result.Equals("wrong"))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Invalid email.');", true);
                    return;
                }

                if (result.Equals("false"))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Something went wrong.');", true);
                    return;
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Email is required.');", true);
                return;
            }
        }
コード例 #7
0
        public bool Save(EmployeeDto employeeDto)
        {
            Employee employee = new Employee
            {
                FirstName   = employeeDto.FirstName,
                LastName    = employeeDto.LastName,
                PhoneNumber = employeeDto.PhoneNumber,
                Email       = employeeDto.Email,
                BirthDate   = employeeDto.BirthDate,
                Position    = employeeDto.Position,
                Salary      = employeeDto.Salary
            };

            try
            {
                using (CompanyRepo repo = new CompanyRepo())
                {
                    repo.EmployeeRepository.Insert(employee);
                    repo.Save();
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #8
0
 public bool Save(ProjectEmployeeDto projectEmployeeDto)
 {
     try
     {
         using (CompanyRepo repo = new CompanyRepo())
         {
             try
             {
                 var pe = new ProjectEmployee()
                 {
                     id_project  = projectEmployeeDto.id_project,
                     project     = repo.ProjectRepository.GetByID(projectEmployeeDto.projectDto.Id),
                     id_employee = projectEmployeeDto.id_employee,
                     empployee   = repo.EmployeeRepository.GetByID(projectEmployeeDto.employeeDto.Id)
                 };
                 repo.ProjectEmployeeRepository.Insert(pe);
                 repo.Save();
                 return(true);
             }
             catch
             {
                 return(false);
             }
         }
         return(true);
     }
     catch
     {
         return(true);
     }
 }
コード例 #9
0
        public ActionResult DeleteConfirm(int id)
        {
            bool result = ProductRepo.Delete(id);

            UserViewModel modul = CompanyRepo.GetIdByName(User.Identity.Name);

            if (modul.Role == "Admin")
            {
                if (CompanyRepo.Delete(id))
                {
                    return(Json(new
                    {
                        success = result,
                        entity = "",
                        message = "delete success"
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        success = result,
                        entity = "",
                        message = "delete fail"
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(new RedirectToRouteResult(new RouteValueDictionary(new { controller = "AccessDenied", action = "Index" })));
            }
        }
コード例 #10
0
        public bool Save(ManagerDto managerDto)
        {
            Manager manager = new Manager
            {
                FirstName   = managerDto.FirstName,
                LastName    = managerDto.LastName,
                PhoneNumber = managerDto.PhoneNumber,
                Email       = managerDto.Email,
                BirthDate   = managerDto.BirthDate,
                Nationality = managerDto.Nationality,
                Salary      = managerDto.Salary
            };

            try
            {
                using (CompanyRepo repo = new CompanyRepo())
                {
                    repo.ManagerRepository.Insert(manager);
                    repo.Save();
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #11
0
        public void CreateCompany_NameIsNullOrWhiteSpace()
        {
            // Arrange
            var repo     = new CompanyRepo(null);
            var company1 = new Company()
            {
                Name = ""
            };
            var company2 = new Company()
            {
                Name = " "
            };
            var company3 = new Company()
            {
                Name = null
            };

            // Act
            var result1 = repo.CreateCompany(company1);
            var result2 = repo.CreateCompany(company2);
            var result3 = repo.CreateCompany(company3);

            // Assert
            Assert.Null(result1);
            Assert.Null(result2);
            Assert.Null(result3);
        }
コード例 #12
0
ファイル: HomeController.cs プロジェクト: zetawars/SmartApp4b
        public ActionResult Attendance(AttendanceViewModel vm)
        {
            if (vm.SelectedCompanies == null)
            {
                vm.SelectedCompanies = new List <string>();
            }
            if (vm.SelectedRegions == null)
            {
                vm.SelectedRegions = new List <string>();
            }
            if (vm.SelectedTerritories == null)
            {
                vm.SelectedTerritories = new List <string>();
            }
            if (vm.SelectedZones == null)
            {
                vm.SelectedZones = new List <string>();
            }
            vm.Companies   = CompanyRepo.GetCompanies(user.UserID);
            vm.Regions     = AttendanceRepo.GetRegions(1, vm.SelectedCompanies.Select(x => x.ToString()).ToList(), user.UserID);
            vm.Zones       = AttendanceRepo.GetZones(1, vm.SelectedCompanies.Select(x => x.ToString()).ToList(), vm.SelectedRegions.Select(x => x.ToString()).ToList(), user.UserID);
            vm.Territories = AttendanceRepo.GeTerritories(1, vm.Companies.Select(x => x.Compcode.ToString()).ToList(), vm.SelectedRegions.Select(x => x.ToString()).ToList(), vm.SelectedZones.Select(x => x.ToString()).ToList(), user.UserID);
            //ViewBag.CreditDebit = AttendanceRepo.GetList(AttendanceRepo.GetWhereClause(vm));

            ViewBag.WhereClause   = AttendanceRepo.GetWhereClause(vm, 1);
            ViewBag.WhereClauseAb = AttendanceRepo.GetWhereAbClause(vm, 1, user.UserID);
            //var list = AttendanceRepo.GetDetails("FirstCheckIn", AttendanceRepo.GetWhereClause(vm), AttendanceRepo.GetWhereAbClause(vm), user.UserID);
            var list = AttendanceRepo.GetDetails("FirstCheckIn", AttendanceRepo.GetWhereClause(vm, 1), AttendanceRepo.GetWhereAbClause(vm, 1, user.UserID), user.UserID);

            ViewBag.ListDetails = list;
            return(View(vm));
        }
コード例 #13
0
        public ManagerDto GetById(int id)
        {
            ManagerDto managerDto = new ManagerDto();

            using (CompanyRepo repo = new CompanyRepo())
            {
                Manager manager = repo.ManagerRepository.GetByID(id);
                if (manager != null)
                {
                    managerDto = new ManagerDto
                    {
                        Id          = manager.Id,
                        FirstName   = manager.FirstName,
                        LastName    = manager.LastName,
                        PhoneNumber = manager.PhoneNumber,
                        Email       = manager.Email,
                        BirthDate   = manager.BirthDate,
                        Nationality = manager.Nationality,
                        Salary      = manager.Salary
                    };
                }
            }

            return(managerDto);
        }
コード例 #14
0
        // GET : Create
        public ActionResult Create()
        {
            UserViewModel model = EmployeeRepo.GetIdByName(User.Identity.Name);

            ViewBag.Company = new SelectList(CompanyRepo.Get(), "id", "Name");
            return(PartialView("_Create", new EmployeeViewModel()));
        }
コード例 #15
0
 // GET: User
 public ActionResult Index()
 {
     ViewBag.Employee = new SelectList(EmployeeRepo.Get(), "FullName", "FullName");
     ViewBag.Role     = new SelectList(RoleRepo.Get(), "Name", "Name");
     ViewBag.Company  = new SelectList(CompanyRepo.Get(), "Name", "Name");
     return(View(UserRepo.Get()));
 }
コード例 #16
0
        public ProjectDto GetById(int id)
        {
            /* ProjectDto projectDto = new ProjectDto();
             *
             * using (CompanyRepo repo = new CompanyRepo())
             * {
             *   Project project = repo.ProjectRepository.GetByID(id);
             *   if (project != null)
             *   {
             *       projectDto = new ProjectDto
             *       {
             *           Id = project.Id,
             *           Name = project.Name,
             *           Description = project.Description,
             *           Created = project.Created,
             *           Client = project.Client,
             *           Price = project.Price,
             *           managerDto = new ManagerDto
             *           {
             *               Id = project.Manager_Id,
             *               FirstName = project.manager.FirstName,
             *               LastName = project.manager.LastName,
             *               PhoneNumber = project.manager.PhoneNumber,
             *               Email = project.manager.Email,
             *               BirthDate = project.manager.BirthDate,
             *               Nationality = project.manager.Nationality,
             *               Salary = project.manager.Salary
             *           }
             *       };
             *   }
             * }
             * return projectDto;*/

            using (CompanyRepo repo = new CompanyRepo())
            {
                var project = repo.ProjectRepository.GetByID(id);
                return(project == null ? null : new ProjectDto
                {
                    Id = project.Id,
                    Name = project.Name,
                    Description = project.Description,
                    Created = project.Created,
                    Client = project.Client,
                    Price = project.Price,
                    managerId = project.Manager_Id,
                    managerDto = new ManagerDto
                    {
                        Id = project.Manager_Id,
                        FirstName = project.manager.FirstName,
                        LastName = project.manager.LastName,
                        PhoneNumber = project.manager.PhoneNumber,
                        Email = project.manager.Email,
                        BirthDate = project.manager.BirthDate,
                        Nationality = project.manager.Nationality,
                        Salary = project.manager.Salary
                    }
                });
            }
        }
コード例 #17
0
        public void ctrl(SqlConnection conn)
        {
            CompanyRepo CR = new CompanyRepo();

            CR.Read(conn);
            CR.CreateOrUpdate(conn, "testcompany");
            Console.ReadLine();
        }
コード例 #18
0
 public IActionResult SaveCompany([FromBody] CompanyModel company)
 {
     if (CompanyRepo.SaveCompany(company) != null)
     {
         return(Ok(company));
     }
     return(StatusCode(500));
 }
コード例 #19
0
        //GET : Edit
        public ActionResult Edit(int id)
        {
            //UserViewModel model2 = EmployeeRepo.GetIdByName(User.Identity.Name);
            ViewBag.Company = new SelectList(CompanyRepo.Get(), "id", "Name");
            EmployeeViewModel model = EmployeeRepo.GetById(id);

            return(PartialView("_Edit", model));
        }
コード例 #20
0
        public CompanyRepo GetCompanyByIdForDisplaying(int _id)
        {
            try
            {
                using (var context = new VeraEntities())
                {
                    var company = context.Company.FirstOrDefault(a => a.Id == _id && a.Status == 1);
                    if (company != null)
                    {
                        var companyUser = context.CompanyUser.FirstOrDefault(b => b.CompanyId == company.Id);
                        var user        = context.User.FirstOrDefault(x => x.Id == companyUser.UserId && x.Status == 1);

                        var returnObj = new CompanyRepo()
                        {
                            Id                        = company.Id,
                            MainCompanyId             = company.MainCompanyId,
                            CompanyTypeId             = company.CompanyTypeId,
                            CompanyPartnerId          = company.CompanyPartnerId,
                            PlatformId                = company.PlatformId,
                            DistributorId             = company.DistributorId,
                            SectorId                  = company.SectorId,
                            Address1                  = company.Address1,
                            CompanyReportId           = company.CompanyReportId,
                            CompanyCode               = company.CompanyCode,
                            CompanyDescription        = company.CompanyDescription,
                            Phone                     = company.Phone,
                            TechnicalReport           = company.TechnicalReport,
                            TechnicalEmail1           = company.TechnicalEmail1,
                            TechnicalEmail2           = company.TechnicalEmail2,
                            TechnicalEmail3           = company.TechnicalEmail3,
                            CompanyStatus             = company.CompanyStatus,
                            AlarmSms                  = company.AlarmSms,
                            PasswordControl           = company.PasswordControl,
                            CompanyVehicleProgramming = company.CompanyVehicleProgramming,
                            CompanyGroupName          = company.CompanyGroupName,
                            CreationDate              = company.CreationDate,
                            UserId                    = user.Id,
                            UserCode                  = user.UserCode,
                            UserEmail                 = user.Mail,
                            UserName                  = user.Name,
                            UserPassword              = user.Password,
                            UserSurname               = user.Surname,
                            UserTelephone             = user.Telephone,
                            UserTypeId                = user.UserTypeId,
                            UserStatus                = company.UserStatus,
                            AccountingCode            = company.AccountingCode
                        };

                        return(returnObj);
                    }
                    return(null);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #21
0
 public AuthController(RecruitmentSystemContext context, SignInManager <SystemUser> signInManager, IServiceProvider serviceProvider, IConfiguration config, SystemUserRepo userRepo, CompanyRepo companyRepo, LabourerRepo labourerRepo)
 {
     _context         = context;
     _signInManager   = signInManager;
     _serviceProvider = serviceProvider;
     _config          = config;
     _userRepo        = userRepo;
     _companyRepo     = companyRepo;
     _labourerRepo    = labourerRepo;
 }
コード例 #22
0
        public IActionResult GetAllCompany(int pp, int page)
        {
            var companyList = CompanyRepo.GetAllCompany(pp, page);

            if (companyList != null)
            {
                return(new ObjectResult(companyList));
            }
            return(StatusCode(500));
        }
コード例 #23
0
        public IActionResult GetCompany(int companyId)
        {
            var company = CompanyRepo.GetCompany(companyId);

            if (company != null)
            {
                return(new ObjectResult(company));
            }
            return(StatusCode(500));
        }
コード例 #24
0
        public IActionResult GetCompanyCount()
        {
            var count = CompanyRepo.GetCompanyCount();

            if (count > -1)
            {
                return(new ObjectResult(count));
            }
            return(StatusCode(500));
        }
コード例 #25
0
        public IActionResult GetCompanySelect()
        {
            var companyList = CompanyRepo.GetCompanySelect();

            if (companyList != null)
            {
                return(new ObjectResult(companyList));
            }
            return(StatusCode(500));
        }
コード例 #26
0
        public static List <string> SearchEmail(string prefixText, int count)
        {
            var           list      = new CompanyRepo().GetListByContainsEmail(prefixText);
            List <string> fullnames = new List <string>();

            foreach (var item in list)
            {
                fullnames.Add(item.EMAIL);
            }
            return(fullnames);
        }
コード例 #27
0
 public ActionResult Edit(CompanyViewModel model)
 {
     if (CompanyRepo.Update(model))
     {
         return(Json(new { success = true, entity = model }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #28
0
 public ActionResult DeleteConfirm(int id)
 {
     if (CompanyRepo.Delete(id))
     {
         return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #29
0
        public ActionResult Edit(int id)
        {
            ViewBag.CompanyType = new SelectList(CompanyRepo.All().Select(p => new { CompanyType = p.客戶分類 }).Distinct(), "CompanyType", "CompanyType");
            var data = CompanyRepo.Find(id);

            if (data == null)
            {
                throw new InvalidOperationException("操作錯誤");
            }
            return(View(data));
        }
コード例 #30
0
 public IActionResult GetCompanyName(int companyId)
 {
     try
     {
         var name = CompanyRepo.GetCompanyName(companyId);
         return(new ObjectResult(name));
     }
     catch (Exception)
     {
         return(StatusCode(500));
     }
 }