/// <summary>
    /// Constructs a new add employee message instance
    /// </summary>
    private EmployeeMessage processAddEmployeeRequest(int index)
    {
        int    ID         = Convert.ToInt32(m_msgQueue[index, 1]);
        string FirstName  = m_msgQueue[index, 2];
        string MiddleName = m_msgQueue[index, 3];
        string LastName   = m_msgQueue[index, 4];
        string SSN        = m_msgQueue[index, 5];

        bool IsSalaried = false;

        if (m_msgQueue[index, 6] == "salaried")
        {
            IsSalaried = true;
        }

        double PayRate = Convert.ToDouble(m_msgQueue[index, 7]);

        if (SSN.Length != 11)
        {
            throw new ArgumentOutOfRangeException(
                      "SSN is of incorrect length!");
        }

        Console.WriteLine("Invoking delegate");
        AddEmployeeMessage msg = new AddEmployeeMessage(MsgType.Add,
                                                        ID, FirstName, LastName, MiddleName, SSN, IsSalaried,
                                                        PayRate);

        return(msg);
    }
Beispiel #2
0
        private AddEmployeeResponseMessage OnAddEmployeeMessage(AddEmployeeMessage message)
        {
            employeeLogic.AddEmployee(message.CompanyId, message.Employee);
            var responseMessage = new AddEmployeeResponseMessage();

            return(responseMessage);
        }
 public AddEmployeEventArgs(AddEmployeeMessage msg)
 {
     m_ID         = msg.ID;
     m_FirstName  = msg.FirstName;
     m_LastName   = msg.LastName;
     m_MiddleName = msg.MiddleName;
     m_SSN        = msg.SSN;
     m_IsSalaried = msg.IsSalaried;
     m_PayRate    = msg.PayRate;
 }
        public override async Task <SuccessReply> AddEmployee(AddEmployeeMessage request, ServerCallContext context)
        {
            var result = await _mediator.Send(new CreateEmployeeCommand {
                Payload = new CreateEmployeeVM
                {
                    FirstName     = request.FirstName,
                    LastName      = request.LastName,
                    JoinDate      = request.JoinDate.ToDateTime(),
                    DepartementId = request.DepartementId
                }
            });

            return(new SuccessReply {
                Success = result.Success, Reason = result.Reason
            });
        }
        public IActionResult Add([FromRoute] int id, AddEmployeeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                // if model state is not valid, redirect user to AddCompany page and list validation errors
                return(BadRequest(ModelState));
            }

            var addEmployeeDto = mapper.Map <AddEmployeeDTO>(model);
            var message        = new AddEmployeeMessage
            {
                Employee  = addEmployeeDto,
                CompanyId = id
            };

            bus.Request <AddEmployeeMessage, AddEmployeeResponseMessage>(message);

            return(RedirectToAction("Details", "Companies", new { id }));
        }