Esempio n. 1
0
        public ActionResult Delete(bool active, int?id)
        {
            if (id == null)
            {
                sb.Clear();
                sb.Append("It needes a id to delete a employee");
                SeriLogHelper.WriteError(null, sb.ToString());

                return(new JsonHttpStatusResult(sb.ToString(), HttpStatusCode.BadRequest));
            }
            try
            {
                var employee = _employeeService.Get(x => x.Id == id && x.Active == !active);

                if (employee == null)
                {
                    sb.Clear();
                    sb.AppendFormat("Employe do not found with the id {0}", id);
                    SeriLogHelper.WriteError(null, sb.ToString());
                    return(new JsonHttpStatusResult(sb.ToString(), HttpStatusCode.NotFound));
                }
                employee.Active = active;
                _employeeService.Update(employee);
                EmployeeDTO employeeDTO = AutoMapperConfiguration.Instance.Mapper.Map <EmployeeDTO>(employee);

                return(Json(employeeDTO, JsonRequestBehavior.DenyGet));
            }
            catch (Exception)
            {
                return(new JsonHttpStatusResult(sb.ToString(), HttpStatusCode.InternalServerError));
            }
        }
 public ActionResult Delete(bool active, int?id)
 {
     if (id == null)
     {
         sb.Clear();
         sb.Append("It needes a Id to delete a Salary tabulator");
         SeriLogHelper.WriteError(null, sb.ToString());
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     try
     {
         SalaryTabulator salaryTabulator = salaryTabuladorService.Get(x => x.Id == id && x.Active == !active);
         if (salaryTabulator == null)
         {
             return(HttpNotFound());
         }
         salaryTabulator.Active = active;
         salaryTabuladorService.Update(salaryTabulator);
         SalaryTabulatorDTO salaryTabulatorDTO = AutoMapperConfiguration.Instance.Mapper.Map <SalaryTabulatorDTO>(salaryTabulator);
         return(Json(salaryTabulatorDTO, JsonRequestBehavior.DenyGet));
     }
     catch (Exception e)
     {
         sb.Clear();
         sb.Append(e.ToString());
         return(new JsonHttpStatusResult(sb.ToString(), HttpStatusCode.InternalServerError));
     }
 }
Esempio n. 3
0
        // GET: Employee/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                sb.Clear();
                sb.Append("BadRequest: It needs the Id for edit a Employee details");
                SeriLogHelper.WriteError(null, sb.ToString());

                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var employee = _employeeService.Get(x => x.Id == id);

            if (employee == null)
            {
                sb.Clear();
                sb.AppendFormat("Employee do not found with the id {0}", id);
                SeriLogHelper.WriteWarning(null, sb.ToString());
                return(HttpNotFound());
            }
            EmployeeDTO employeeDTO         = AutoMapperConfiguration.Instance.Mapper.Map <EmployeeDTO>(employee);
            var         departamentsDTO     = AutoMapperConfiguration.Instance.Mapper.Map <IEnumerable <DepartamentDTO> >(_departamentService.GetAll());
            var         salaryTabulatorsDTO = AutoMapperConfiguration.Instance.Mapper.Map <IEnumerable <SalaryTabulatorDTO> >(_salaryTabulatorService.GetAll());

            ViewBag.DepartamentId     = new SelectList(departamentsDTO, "Id", "Name", employeeDTO.DepartamentId);
            ViewBag.SalaryTabulatorId = new SelectList(salaryTabulatorsDTO, "Id", "Key", employeeDTO.SalaryTabulatorId);
            return(View(employeeDTO));
        }
        // GET: SalaryTabulator/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                sb.Clear();
                sb.Append("BadRequest: It needs the Id for edit a Salary Tabulator");
                SeriLogHelper.WriteError(null, sb.ToString());
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SalaryTabulator salaryTabulator = salaryTabuladorService.Get(x => x.Id == id);

            if (salaryTabulator == null)
            {
                sb.Clear();
                sb.AppendFormat("Salary tabulator  do not found with the id {0}", id);
                SeriLogHelper.WriteWarning(null, sb.ToString());
                return(HttpNotFound());
            }
            var salaryTabulatorDTO = AutoMapperConfiguration.Instance.Mapper.Map <SalaryTabulatorDTO>(salaryTabulator);
            var jobs    = jobService.GetMany(x => x.Active == true);
            var jobsDTO = AutoMapperConfiguration.Instance.Mapper.Map <IEnumerable <JobDTO> >(jobs);

            ViewBag.JobId = new SelectList(jobsDTO, "Id", "Name", salaryTabulatorDTO.JobId);
            return(View(salaryTabulatorDTO));
        }
Esempio n. 5
0
 public void TestSeriLog()
 {
     try
     {
         SeriLogHelper.WriteDebug(null, "Debug ");
         Debug.WriteLine("Debug");
         SeriLogHelper.WriteWarning(null, "Warning ");
         throw new NotImplementedException();
     }
     catch (Exception e)
     {
         SeriLogHelper.WriteError(e, "Error");
         SeriLogHelper.WriteFatal(e, "Fatal");
         SeriLogHelper.WriteVerbose(e, "Verbose");
         throw;
     }
 }
        public JsonResult getAll(DataTableInput input)
        {
            DataTableOutput <SalaryTabulator>    salaryTabulators    = new DataTableOutput <SalaryTabulator>();
            DataTableOutput <SalaryTabulatorDTO> salaryTabulatorsDTO = new DataTableOutput <SalaryTabulatorDTO>();

            try
            {
                salaryTabulators    = salaryTabuladorService.GetSalarysTabulators(input);
                salaryTabulatorsDTO = AutoMapperConfiguration.Instance.Mapper.Map <DataTableOutput <SalaryTabulatorDTO> >(salaryTabulators);
            }
            catch (Exception e)
            {
                sb.Clear();
                sb.Append("An error has ocurred when it try to retrieve Salary Tabulators");
                SeriLogHelper.WriteError(e, sb.ToString());
                return(new JsonHttpStatusResult(e.Message, HttpStatusCode.InternalServerError));
            }
            return(Json(salaryTabulatorsDTO, JsonRequestBehavior.DenyGet));
        }
Esempio n. 7
0
        public JsonResult CustomServerSideSearchAction(DataTableVM <PaymentSearch> model)
        {
            DataTableOutput <Payment>    payments    = new DataTableOutput <Payment>();
            DataTableOutput <PaymentDTO> paymentsDTO = new DataTableOutput <PaymentDTO>();

            try
            {
                payments    = _paymentService.GetByFilters(model.Filters.Employee ?? null, model.Filters.DepartamentId ?? null, model.dataTablesInput ?? null);
                paymentsDTO = AutoMapperConfiguration.Instance.Mapper.Map <DataTableOutput <PaymentDTO> >(payments);
            }
            catch (Exception e)
            {
                sb.Clear();
                sb.Append("An error has occurred when it try to retrieve payments");
                SeriLogHelper.WriteError(e, sb.ToString());
                return(new JsonHttpStatusResult(e.Message, HttpStatusCode.BadRequest));
            }
            return(Json(paymentsDTO, JsonRequestBehavior.DenyGet));
        }
Esempio n. 8
0
        //GET: Employee/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                sb.Clear();
                sb.Append("BadRequest: It needs the Id for request the Employee ");
                SeriLogHelper.WriteError(null, sb.ToString());
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            EmployeeDTO employeeDTO = AutoMapperConfiguration.Instance.Mapper.Map <EmployeeDTO>(_employeeService.GetByID(id));

            if (employeeDTO == null)
            {
                sb.Clear();
                sb.AppendFormat("Not found the employee with id {0}", id);
                SeriLogHelper.WriteWarning(null, sb.ToString());
                return(HttpNotFound());
            }
            return(View(employeeDTO));
        }
Esempio n. 9
0
        public JsonResult CustomServerSideSearchAction(DataTableVM <SearchEmployee> model)
        {
            DataTableOutput <Employee>    employees    = new DataTableOutput <Employee>();
            DataTableOutput <EmployeeDTO> employeesDTO = new DataTableOutput <EmployeeDTO>();

            try
            {
                employees = _employeeService.GetByFilters(model.Filters.KeyEmplooye ?? null,
                                                          model.Filters.Name ?? null, model.Filters.DepartamentId ?? null, model.Filters.SalaryTabulatorId ?? null, model.dataTablesInput ?? null);
                employeesDTO = AutoMapperConfiguration.Instance.Mapper.Map <DataTableOutput <EmployeeDTO> >(employees);
            }
            catch (Exception e)
            {
                sb.Clear();
                sb.Append("An error has occurred when it try to retrieve employees");
                SeriLogHelper.WriteError(e, sb.ToString());
                return(new JsonHttpStatusResult(e.Message, HttpStatusCode.BadRequest));
            }
            Debug.Write(JsonConvert.SerializeObject(employeesDTO));
            return(Json(employeesDTO, JsonRequestBehavior.DenyGet));
        }
Esempio n. 10
0
        // GET: SalaryTabulator/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                sb.Clear();
                sb.Append("BadRequest: It needs the Id for request the SalaryTabulator details");
                SeriLogHelper.WriteError(null, sb.ToString());
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var salaryTabulator    = salaryTabuladorService.Get(x => x.Id == id);
            var salaryTabulatorDTO = AutoMapperConfiguration.Instance.Mapper.Map <SalaryTabulatorDTO>(salaryTabulator);

            if (salaryTabulatorDTO == null)
            {
                sb.Clear();
                sb.AppendFormat("Not found the salary tabulator with id {0}", id);
                SeriLogHelper.WriteWarning(null, sb.ToString());
                return(HttpNotFound());
            }
            return(View(salaryTabulatorDTO));
        }