Exemplo n.º 1
0
        public override void Create(RequestEmployee requestEmployee)
        {
            var requestEmployeeMonthlySalary = new RequestEmployeeMonthlySalary(requestEmployee);

            var salary = new Money(requestEmployeeMonthlySalary.Amount, Currency.USD);

            var monthlySalaryContract = new MonthlySalaryContract(salary);

            var employee = new Employee(requestEmployeeMonthlySalary.Name, requestEmployee.LastName, monthlySalaryContract.TypeContract, monthlySalaryContract.Salary, monthlySalaryContract.AnnualSalary, requestEmployeeMonthlySalary.IdRole);

            _employeeService.Save(employee);
        }
        public async Task <ActionResult> UpdateEmployee(RequestEmployee requestEmployee)
        {
            try
            {
                await _employeesLogic.ActionCRUD(requestEmployee, 3);

                return(Json(new { status = "success", title = "Update Employee Success.", text = "" }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "failed", title = "Update Employee Failed", text = ex.Message.ToString() }));

                throw;
            }
        }
 public abstract void Create(RequestEmployee requestEmployee);
 public void Save(RequestEmployee requestEmployeeMonthlySalary)
 {
     _employeeMonthlySalary.Create(requestEmployeeMonthlySalary);
 }
 public void SaveEmployeeHourlySalary(RequestEmployee requestEmployeeHourlySalary)
 {
     _employeeHourlySalary.Create(requestEmployeeHourlySalary);
 }
Exemplo n.º 6
0
 public async Task ActionCRUD(RequestEmployee data, int action)
 {
     try
     {
         using (var db = new AgilisDBContext())
         {
             SqlParameter[] prm = new SqlParameter[]
             {
                 new SqlParameter("@Action", SqlDbType.Int)
                 {
                     Value = action
                 },
                 new SqlParameter("@Nik", SqlDbType.NVarChar)
                 {
                     Value = data.NIK == null ? "" : data.NIK
                 },
                 new SqlParameter("@FirtsName", SqlDbType.NVarChar)
                 {
                     Value = data.FirstName == null ? "" : data.FirstName
                 },
                 new SqlParameter("@LastName", SqlDbType.NVarChar)
                 {
                     Value = data.LastName == null ? "": data.LastName
                 },
                 new SqlParameter("@Address", SqlDbType.NVarChar)
                 {
                     Value = data.Address == null ? "" : data.Address
                 },
                 new SqlParameter("@Gender", SqlDbType.NVarChar)
                 {
                     Value = data.Gender == null ? "" :data.Gender
                 },
                 new SqlParameter("@PlaceOfBirth", SqlDbType.NVarChar)
                 {
                     Value = data.PlaceOfBirth == null ? "":data.PlaceOfBirth
                 },
                 new SqlParameter("@DateOfBirth", SqlDbType.NVarChar)
                 {
                     Value = data.DateOfBirth == null ? "" : data.DateOfBirth
                 },
                 new SqlParameter("@Email", SqlDbType.NVarChar)
                 {
                     Value = data.Email == null ? "" : data.Email
                 },
                 new SqlParameter("@Phone", SqlDbType.NVarChar)
                 {
                     Value = data.Phone == null ? "" : data.Phone
                 },
                 new SqlParameter("@JobTitleID", SqlDbType.NVarChar)
                 {
                     Value = data.JobTitle == null ? "" : data.JobTitle
                 },
                 new SqlParameter("@HireDate", SqlDbType.NVarChar)
                 {
                     Value = data.HiresDate == null ? "" : data.HiresDate
                 },
                 new SqlParameter("@DepartID", SqlDbType.NVarChar)
                 {
                     Value = data.Department == null ? "" : data.Department
                 },
                 new SqlParameter("@IdEmployee", SqlDbType.BigInt)
                 {
                     Value = data.ID
                 }
             };
             await db.Database.ExecuteSqlCommandAsync(DbHelper.GenerateCommandText("usp_Employees", prm), prm);
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }