예제 #1
0
        private bool checkVacaionDaysEdit(EmployeeRequest employeeRequest, int currval)
        {
            List <VacationView> vacationViews = _employeeBalanceRepo.GetAllEmployeeBalances();
            var vacationview = vacationViews.Find(v => v.employeeID == employeeRequest.EmployeeID && v.vacationID == employeeRequest.VacationID);

            return(employeeRequest.Days > (vacationview.Balance - (vacationview.Used - currval)));
        }
        public ActionResult UpdateEmployee(EmployeeRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            try
            {
                var employee = _mapper.Map <EmployeeRequest, Employee>(request);
                if (employee.Notifications.Any())
                {
                    return(CustomResponse(employee.Notifications));
                }
                _employeeAppService.UpdateEmployee(employee);

                var employeeResponse = _mapper.Map <Employee, EmployeeResponse>(employee);
                return(CustomResponse(employeeResponse));
            }
            catch (Exception ex)
            {
                MessageException();
                return(CustomExceptionResponse());
            }
        }
예제 #3
0
        public ActionResult Delete(int EmployeeID, int ServiceRequestId)
        {
            n.DateAccessed   = DateTime.Now;
            n.TableAccessed  = "Employee Request";
            n.ChangesMade    = "Unassigned employee";
            n.AuditLogTypeID = 4;
            n.UserID         = EmployeeID;
            db.AuditLogs.Add(n);

            EmployeeRequest employeeRequest = db.EmployeeRequests.Where(x => x.EmployeeID == EmployeeID & x.ServiceRequestID == ServiceRequestId).FirstOrDefault();

            db.EmployeeRequests.Remove(employeeRequest);

            db.SaveChanges();

            //HttpResponseMessage response = GlobalVariables.WebAPIClient.DeleteAsync("EmployeeRequest/" + id.ToString()).Result;
            TempData["SuccessMessage"] = "Deleted Successfully";

            var EmployeeRequests = db.EmployeeRequests.Where(x => x.ServiceRequestID == ServiceRequestId).ToList();

            if (EmployeeRequests.Count() == 0)
            {
                var temp = db.ServiceRequests.Find(employeeRequest.ServiceRequestID);
                temp.ServiceRequestStatusID = 2;
                db.Entry(temp).State        = EntityState.Modified;
                db.SaveChanges();
            }

            ServiceRequestID = ServiceRequestId;
            return(RedirectToAction("AddorEdit", "EmployeeRequest"));
        }
        public override async Task <EmployeeResponse> Save(EmployeeRequest request, ServerCallContext context)
        {
            try
            {
                var metadata = context.RequestHeaders;
                foreach (var pair in metadata)
                {
                    _logger.LogInformation($"{pair.Key}: {pair.Value}");
                }

                InMemoryData.Employees.Add(request.Employee);

                var response = new EmployeeResponse
                {
                    Employee = InMemoryData.Employees.SingleOrDefault(x => x.No == request.Employee.No)
                };

                Console.WriteLine("Employees:");
                foreach (var employee in InMemoryData.Employees)
                {
                    Console.WriteLine(employee);
                }

                return(await Task.FromResult(response));
            }
            catch (RpcException re)
            {
                throw;
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                throw new RpcException(Status.DefaultCancelled, e.Message);
            }
        }
예제 #5
0
 /// <summary>
 /// Busqueda de venta por folio
 /// </summary>
 /// <param name="folio"></param>
 /// <param name="esDevolucion"></param>
 /// <returns>Venta correspondiente</returns>
 public ResponseBussiness <VentaResponse> BuscarVentaPorFolio(string folio, int esDevolucion)
 {
     return(tryCatch.SafeExecutor(() =>
     {
         VentaResponse ventaResponse = repository.ObtenerVentaPorFolio(folio, esDevolucion);
         if (ventaResponse.NumeroNominaVentaEmpleado != 0)
         {
             ventaResponse.InformacionEmpleadoMilano = new AdministracionVentaEmpleadoBusiness().Buscar(ventaResponse.NumeroNominaVentaEmpleado.ToString(), this.token.CodeStore.ToString(), this.token.CodeBox.ToString());
         }
         else if (ventaResponse.CodigoMayorista != 0)
         {
             BusquedaMayoristaRequest busquedaMayorista = new BusquedaMayoristaRequest();
             busquedaMayorista.CodigoMayorista = ventaResponse.CodigoMayorista;
             busquedaMayorista.Nombre = "";
             busquedaMayorista.SoloActivos = true;
             ventaResponse.InformacionMayorista = new MayoristasBusiness(this.token).BusquedaMayorista(busquedaMayorista);
         }
         if (ventaResponse.CodigoEmpleadoVendedor > 0)
         {
             EmployeeRequest employeeRequest = new EmployeeRequest();
             employeeRequest.Code = ventaResponse.CodigoEmpleadoVendedor;
             employeeRequest.Name = "";
             ventaResponse.InformacionEmpleadoVendedor = new EmployeeBusiness(this.token).SearchEmployee(employeeRequest).Data[0];
         }
         return ventaResponse;
     }));
 }
        public async Task TestPostEmployeeAsync()
        {
            // Arrange
            var controller = ControllerMocker.GetEmployeeController(nameof(TestPostEmployeeAsync));

            var request = new EmployeeRequest
            {
                EmployeeId           = 2,
                IdentificationTypeId = 1,
                IdentityNumber       = "1",
                PassportCountryId    = 1,
                FirstName            = "FirstName",
                LastName             = "",
                FirstNameEN          = "",
                LastNameEN           = "",
                OrganizationId       = 1,
                BirthDate            = new DateTime(2000, 5, 1),
                GenderId             = 1,
                Citizenship          = 1,
                ProffesionTypeId     = 1,
                PhoneNumber          = "787545"
            };

            // Act
            var response = await controller.PostEmployeeAsync(request) as ObjectResult;

            var value = response.Value as ISingleResponse <EmployeeResponse>;

            // Assert
            Assert.False(value.DIdError);
        }
예제 #7
0
        public ActionResult EmployeeEdit(EmployeeEditorViewModel model)
        {
            var request = new Request()
            {
                Subject = "Employee Edit - " + model.FirstName + model.Surname, Requester = model.EditedBy, Category = Categories.Employee, Subcategory = "Employee Transfer", Status = Status.AwaitingApproval
            };

            context.Request.Add(request);


            var employee = new Employee()
            {
                EmployeeId = model.EmployeeId, FirstName = model.FirstName, PreferredName = model.PreferredName, Surname = model.Surname,
                Division   = model.BusinessDivision, Department = model.Department, Gender = model.Gender, kingdomName = model.kingdomName, ReportingManager = model.ReportingManager,
                ShadowUser = model.ShadowUser, BusinessUnitId = model.BusinessUnitId
            };

            context.Employee.Add(employee);

            var employeerequest = new EmployeeRequest()
            {
            };

            context.EmployeeRequest.Add(employeerequest);

            context.SaveChanges();
            return(RedirectToAction("Index"));
        }
        private EmployeeResponse InitializeResponse(EmployeeRequest req)
        {
            EmployeeResponse res = new EmployeeResponse();

            res.RequestId = req.RequestId;

            return(res);
        }
예제 #9
0
 public override async Task <EmployeeResponse> Save(EmployeeRequest request, ServerCallContext context)
 {
     InMemoryData.Employees.Add(request.Employee);
     return(new EmployeeResponse()
     {
         Employee = request.Employee
     });
 }
        public EmployeeRequest DeleteEmployeeRequest(int id)
        {
            EmployeeRequest employeeRequest = GetEmployeeRequest(id);

            context.Remove(employeeRequest);
            //context.SaveChanges();
            return(employeeRequest);
        }
예제 #11
0
        public override Task <Employee> GetEmployee(EmployeeRequest request, ServerCallContext context)
        {
            var employee = _db.Employees.FirstOrDefault(emp => emp.Id == request.Id);

            return(Task.FromResult(new Employee {
                Name = employee.Name, Age = employee.Age, Id = employee.Id, Status = employee.Status
            }));
        }
예제 #12
0
        public EmployeeResponse SaveEmployee(EmployeeRequest employeeRequest)
        {
            EmployeeResponse employeeResponse = new EmployeeResponse();

            #region Database activity
            #endregion
            return(employeeResponse);
        }
예제 #13
0
        public async Task <IActionResult> Patch([FromRoute] int id, [FromBody] EmployeeRequest request)
        {
            var employee = Mapper.Map <Employee>(request);

            employee.Id = id;

            return(await AddOrUpdate(employee));
        }
 private static void ModifyRequest(EmployeeRequest request)
 {
     if (string.IsNullOrEmpty(request.RequestId))
     {
         request.RequestId = Guid.NewGuid().ToString();
     }
     request.EmployeeRequestDetails.ForEach(i => i.Token = request.Token);
 }
예제 #15
0
        public EmployeeResponse Get(EmployeeRequest request)
        {
            var employees = EmployeeStore.Get(request);

            return(new EmployeeResponse
            {
                Employees = employees.ToArray()
            });
        }
예제 #16
0
 public async Task Update(Guid id, EmployeeRequest employeeRequest)
 {
     var employee = new Employee
     {
         Id     = id,
         UserId = employeeRequest.UserId
     };
     await _employeeRepo.Update(employee);
 }
        bool UpdateEmployeebyApi(EmployeeRequest employeeRequest, int employeeId)
        {
            string requestURL = "http://dummy.restapiexample.com/api/v1/update/" + employeeId;

            // Make a API call to above RequestURL
            // IF Success return True
            // Else throw an exception
            return(false);
        }
예제 #18
0
        public override Task <DeleteEmployeeResult> DeleteEmployee(EmployeeRequest request, ServerCallContext context)
        {
            var employee = _db.Employees.FirstOrDefault(emp => emp.Id == request.Id);

            _db.Employees.Remove(employee);
            _db.SaveChanges();
            return(Task.FromResult(new DeleteEmployeeResult {
                Success = true
            }));
        }
        public EmployeeResponse InsertEmployee(EmployeeRequest request)
        {
            EmployeeResponse       response           = new EmployeeResponse();
            EmployeeDto            employeeDto        = request.EmployeeDto;
            EmployeeRepository     employeeRepository = northWindUnitOfWork.EmployeeRepository;
            EntityEntry <Employee> employee           = employeeRepository.Add(employeeDto.ToEntity <EmployeeDto, Employee>());

            response.EmployeeId = employee.Entity.EmployeeId;
            return(response);
        }
예제 #20
0
 public async Task Delete(Guid id, EmployeeRequest employeeRequest)
 {
     var employee = new Employee
     {
         Id        = id,
         UserId    = employeeRequest.UserId,
         IsDeleted = true
     };
     await _employeeRepo.Update(employee);
 }
예제 #21
0
        public async Task <Guid> Create(EmployeeRequest employeeRequest)
        {
            var employee = new Employee
            {
                Id     = Guid.NewGuid(),
                UserId = employeeRequest.UserId
            };
            await _employeeRepo.Add(employee);

            return(employee.Id);
        }
예제 #22
0
        public void AddOk()
        {
            // Act
            EmployeeRequest employee = new EmployeeRequest {
                Name = "Тест Тестович Тестовый", Position = "Специалист по тестам", Department = "Отдел тестирования", StartDate = DateTime.Now
            };
            var actionResult = _controller.Add(employee);

            // Assert
            Assert.IsType <OkResult>(actionResult);
        }
        public IActionResult InsertEmpoloyee([FromBody] EmployeeRequest request)
        {
            EmployeeResponse response = TransactionProcessor <NorthWindContext> .Execute
                                        (
                employeeTransactions.InsertEmployee,
                request,
                unitOfWork
                                        );

            return(new JsonResult(response));
        }
        // Custom Function - Aska
        // GET: Requests/InputRequest
        public ActionResult InputRequest()
        {
            EmployeeRequest empReq        = new EmployeeRequest();
            string          currentUserId = User.Identity.GetUserId();
            ApplicationUser currentUser   = (db.Users.Include(r => r.Employee).Include(r => r.Employee.Campaigns).FirstOrDefault(x => x.Id == currentUserId));

            empReq.employee = currentUser.Employee;
            ViewBag.CamID   = new SelectList(db.Campaigns, "CamID", "CamName");
            ViewBag.EmpID   = new SelectList(db.Employees, "EmpID", "EmpName");
            return(View(empReq));
        }
예제 #25
0
        public override Task <EmployeeResponse> Save(EmployeeRequest request, ServerCallContext context)
        {
            MemoryData.Employees.Add(request.Employee);

            var employee = new EmployeeResponse
            {
                Employee = request.Employee
            };

            return(Task.FromResult(employee));
        }
예제 #26
0
        public async Task <ActionResult <EmployeeResponse> > Post(EmployeeRequest employeeRequest)
        {
            if (!EmployeeExists(employeeRequest.SerialNumber))
            {
                var employee = ConvertEmployeeRequestToEmployee(employeeRequest);
                await _service.AddAsync(employee);

                return(CreatedAtAction(nameof(GetItem), new { id = employee.Id }, ConvertEmployeeToEmployeeResponse(employee)));
            }
            return(new ConflictObjectResult(new { message = $"Already exists a job with this serial number {employeeRequest.SerialNumber}" }));
        }
예제 #27
0
        public async Task <HttpResponseMessage> GetById([FromUri] EmployeeRequest request)
        {
            if (request == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            var result = await _employeeService.GetById(request);

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
        public EmployeeInfo GetEmployee(EmployeeRequest employeeRequest)
        {
            var employee = GetAllEmployees().FirstOrDefault(e => e.EmployeeId == employeeRequest.EmployeeId);

            if (employee == null)
            {
                throw new FaultException <ErrorInformation>(new ErrorInformation($"No existe un registro del " +
                                                                                 $"empleado con el Id {employeeRequest.EmployeeId}", MessageType.Error));
            }
            return(new EmployeeInfo(employee));
        }
예제 #29
0
        public EmployeeInfo GetEmployee(EmployeeRequest request)
        {
            Console.WriteLine("License key = " + request.LicenseKey);

            var empFact = new EmployeeFactory();

            var employee = empFact.GetFromDb(request.EmployeeId);

            var employeeInfo = EmployeeInfo.ConvertToEmployeeInfo(employee);

            return employeeInfo;
        }
예제 #30
0
 public static Employee ToEmployee(Employee employee, EmployeeRequest employeeRequest, List <Employee> employees)
 {
     employee.FirstName      = employeeRequest.FirstName;
     employee.LastName       = employeeRequest.LastName;
     employee.BirthDate      = employeeRequest.BirthDate;
     employee.EmploymentDate = employeeRequest.EmploymentDate;
     employee.Address        = employeeRequest.Address;
     employee.Salary         = employeeRequest.Salary;
     employee.Role           = employeeRequest.Role;
     employee.Boss           = employees.FirstOrDefault(x => x.Id == employeeRequest.BossId);
     return(employee);
 }
예제 #31
0
        public async Task <ActionResult <EmployeeRequest> > PostEmployeeRequest(EmployeeRequest employeeRequest)
        {
            if (_employeeRequestService.employeeRequestValidationPost(employeeRequest))
            {
                return(BadRequest());
            }

            _employeeRequestService.AddEmployeeRequest(employeeRequest);
            _employeeRequestService.SaveEmployeeRequest();

            return(CreatedAtAction("GetEmployeeRequest", new { id = employeeRequest.ID }, employeeRequest));
        }