Ejemplo 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));
            }
        }
Ejemplo n.º 2
0
 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));
     }
 }
Ejemplo n.º 3
0
        // 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));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
        public void Configuration(IAppBuilder app)
        {
            app.UseCors(CorsOptions.AllowAll);
            ConfigureAuth(app);
            app.Map("/signalr", map =>
            {
                //CorsPolicyProvider provider = new EnableCorsAttribute("*", "*", "*");
                CorsOptions options = CorsOptions.AllowAll;
                //options.PolicyProvider =
                map.UseCors(options);

                map.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions
                {
                    Provider = new OAuthTokenProvider()
                });

                var hubConfiguration = new HubConfiguration
                {
                    Resolver = GlobalHost.DependencyResolver
                };
                map.RunSignalR(hubConfiguration);
            });

            string name = ConfigurationManager.AppSettings["LoggingDefaults"];

            SeriLogHelper.ConfigureLoggingDefaults(name);
            CacheConfig.Register();
        }
Ejemplo n.º 6
0
        // GET: SalaryTabulator
        public ActionResult Index()
        {
            sb.Clear();
            sb.Append("Retrieve Salary tabulators");
            SeriLogHelper.WriteInformation(null, sb.ToString());
            var salaryTabulatorsDTO = new List <SalaryTabulatorDTO>();

            return(View(salaryTabulatorsDTO));
        }
Ejemplo n.º 7
0
        // GET: Employee
        public ActionResult Index()
        {
            sb.Clear();
            sb.Append("Retrieve employees");
            SeriLogHelper.WriteInformation(null, sb.ToString());
            var employees = new List <EmployeeDTO>();

            ViewBag.DepartamentId     = new SelectList(AutoMapperConfiguration.Instance.Mapper.Map <IEnumerable <DepartamentDTO> >(_departamentService.GetMany(x => x.Active == true)), "Id", "Name");
            ViewBag.SalaryTabulatorId = new SelectList(AutoMapperConfiguration.Instance.Mapper.Map <IEnumerable <SalaryTabulatorDTO> >(_salaryTabulatorService.GetMany(x => x.Active == true)), "Id", "Key");

            return(View(employees));
        }
Ejemplo n.º 8
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            System.Web.Http.GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            string name = ConfigurationManager.AppSettings["LoggingDefaults"];

            SeriLogHelper.ConfigureLoggingDefaults(name);
            System.Web.Http.GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = System.Web.Http.IncludeErrorDetailPolicy.Always;
            System.Web.Http.GlobalConfiguration.Configuration.Services.Add(typeof(IExceptionLogger), new CustomExceptionHandler());
            //Hangfire.GlobalConfiguration.Configuration.UseSqlServerStorage("DefaultSchedulerConnection").UseDashboardMetric(SqlServerStorage.ActiveConnections);

            //SampleScheduler.Start();
        }
Ejemplo n.º 9
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;
     }
 }
Ejemplo n.º 10
0
        public void Configuration(IAppBuilder app)
        {
            app.UseCors(CorsOptions.AllowAll);
            //ConfigureAuth(app);
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions
            {
                Provider = new OAuthTokenProvider()
            });


            app.MapSignalR();
            string name = ConfigurationManager.AppSettings["LoggingDefaults"];

            SeriLogHelper.ConfigureLoggingDefaults(name);
            //GlobalConfiguration.Configuration.UseSqlServerStorage("DefaultSchedulerConnection");
            //app.UseHangfireDashboard();
            //app.UseHangfireServer();
        }
Ejemplo n.º 11
0
        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));
        }
Ejemplo n.º 12
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));
        }
Ejemplo n.º 13
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));
        }
Ejemplo n.º 14
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));
        }
Ejemplo n.º 15
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));
        }
Ejemplo n.º 16
0
        public JsonResult EditJson(SalaryTabulatorDTO salaryTabulatorDTO)
        {
            if ((int)salaryTabulatorDTO.TabulatorLevel == 0)
            {
                sb.Clear();
                sb.Append("It needs a tabulator level to edit a salary tabulator");
                SeriLogHelper.WriteWarning(null, sb.ToString());
                var data = new ErrorByKey[1] {
                    new ErrorByKey {
                        key = "TabulatorLevel", errors = new string[1] {
                            "Requerido"
                        }
                    }
                };
                return(new JsonHttpStatusResult(data, HttpStatusCode.BadRequest));
            }
            var salaryTabulator = AutoMapperConfiguration.Instance.Mapper.Map <SalaryTabulator>(salaryTabulatorDTO);

            salaryTabuladorService.Update(salaryTabulator);
            return(Json(salaryTabulatorDTO, JsonRequestBehavior.DenyGet));
        }
Ejemplo n.º 17
0
        public JsonResult EditJson(EmployeeDTO employeeDTO)
        {
            if ((int)employeeDTO.Gender == 0)
            {
                sb.Clear();
                sb.Append("It needs a gender to edit a employee");
                SeriLogHelper.WriteWarning(null, sb.ToString());
                var data = new ErrorByKey[1] {
                    new ErrorByKey {
                        key = "Gender", errors = new string[1] {
                            "Requerido"
                        }
                    }
                };
                return(new JsonHttpStatusResult(data, HttpStatusCode.BadRequest));
            }

            var employee = AutoMapperConfiguration.Instance.Mapper.Map <Employee>(employeeDTO);

            _employeeService.Update(employee);
            return(Json(employeeDTO, JsonRequestBehavior.DenyGet));
        }
Ejemplo n.º 18
0
        public void Test1()
        {
            var configuration = new ConfigHelper().Configuration;
            var appSettings   = TestHelpers.GetAppSettings();

            using var logConfig = SeriLogHelper.CreateLoggerConfig(configuration, appSettings);
            var requestTraceId = $"Test-{DateTime.Now.ToString("yyyyMMddhhmmss")}";

            var logger  = SeriLogHelper.GetLogger <UnitTest1>(logConfig);
            var options = new Dictionary <string, object> {
                { "requestTraceId", requestTraceId }
            };

            using (logger.BeginScope(options))
            {
                logger.LogInformation("Should_Upload_Products starting");
                logger.LogDebug("Should_Upload_Products starting");
                logger.LogWarning("Should_Upload_Products starting");
                logger.LogError("Should_Upload_Products starting");
                logger.LogInformation("Should_Upload_Products complete");
            }
        }
Ejemplo n.º 19
0
 private void Form1_Load(object sender, EventArgs e)
 {
     SeriLogHelper.Info("fdfdsf");
 }