Пример #1
0
        public async Task <JsonResult> SearchWorkPlace(string value, decimal salary, int elmPage)
        {
            int?page = 1;

            if (elmPage == 0)
            {
                elmPage = 10;
            }
            int     elmpage   = elmPage;
            decimal pageCount = 0;
            Paging  paging    = new Paging();

            paging.CurrentPage = (int)page;
            paging.ItemPage    = elmpage;
            paging.Prev        = page > 1;

            List <EmployeeInfoWorkPlace> places       = new List <EmployeeInfoWorkPlace>();
            EmployeeWorkPlace            employeeWork = new EmployeeWorkPlace();
            var currentdata = await employeeWork.EmployeeInfoWorks(dbContext);


            if (value != null)
            {
                var searchData = currentdata.Where(x => x.PositionName.Contains(value) || x.PositionName.StartsWith(value) ||
                                                   x.CompanyName.Contains(value) || x.CompanyName.StartsWith(value) ||
                                                   x.EmperiumName.Contains(value) || x.EmperiumName.StartsWith(value) ||
                                                   x.Name.Contains(value) || x.Name.StartsWith(value) ||
                                                   x.PlasierCode.Contains(value) || x.PlasierCode.StartsWith(value) ||
                                                   x.Salary == salary).ToList();


                paging.TotalItems = searchData.Count();
                pageCount         = Math.Ceiling(searchData.Count() / (decimal)elmpage);
                paging.Next       = page < pageCount;

                var datapaging = searchData.Skip((paging.CurrentPage - 1) * elmpage).Take(elmpage).ToList();
                return(Json(new { pageCount = pageCount, currentPage = paging.CurrentPage, allData = searchData, nextElement = paging.Next, prevElement = paging.Prev, data = datapaging, message = 202 }));
            }

            paging.TotalItems = currentdata.Count();
            pageCount         = Math.Ceiling(currentdata.Count() / (decimal)elmpage);
            paging.Next       = page < pageCount;
            var data = currentdata.Skip((paging.CurrentPage - 1) * elmpage).Take(elmpage).ToList();

            return(Json(new { pageCount = pageCount, currentPage = paging.CurrentPage, allData = currentdata, nextElement = paging.Next, prevElement = paging.Prev, data = data, message = 202 }));
        }
Пример #2
0
        public dynamic Fired(EmployeeWorkPlace employeeWorkPlace)
        {
            string query;

            switch (employeeWorkPlace.Type)
            {
            case 1:
                query = $"Delete from EmployeeStore where idEmployee='{employeeWorkPlace.IdEmployee}' AND idStore='{employeeWorkPlace.IdOffice}'";
                SqlQuery(query);
                break;

            case 2:
                query = string.Format("Delete from EmployeeWareHouse where idEmployee = '{0}' AND idWareHouse = '{1}'", employeeWorkPlace.IdEmployee, employeeWorkPlace.IdOffice);
                SqlQuery(query);
                break;
            }
            return(Save());
        }
Пример #3
0
        public dynamic Hire(EmployeeWorkPlace employeeWorkPlace)
        {
            string query;

            switch (employeeWorkPlace.Type)
            {
            case 1:
                query = string.Format("Insert into EmployeeStore values ('{0}','{1}')", employeeWorkPlace.IdEmployee, employeeWorkPlace.IdOffice);
                SqlQuery(query);
                break;

            case 2:
                query = string.Format("Insert into EmployeeWareHouse values ('{0}','{1}')", employeeWorkPlace.IdEmployee, employeeWorkPlace.IdOffice);
                SqlQuery(query);
                break;
            }
            return(Save());
        }
Пример #4
0
 public IHttpActionResult FiredEmployee(EmployeeWorkPlace employeeWorkPlace)
 {
     return(Ok(_service.Fired(employeeWorkPlace)));;
 }
Пример #5
0
 public IHttpActionResult HireEmployee(EmployeeWorkPlace hire)
 {
     return(Ok(_service.Hire(hire)));;
 }
Пример #6
0
 public dynamic Fired(EmployeeWorkPlace EmployeeDtoWorkPlace)
 {
     throw new NotImplementedException();
 }