Exemple #1
0
        public async Task<ActionResult<DBEmployee>> PostEmployee(DBEmployee employee)
        {
            _context.Employee.Add(employee);
            await _context.SaveChangesAsync();

            return CreatedAtAction("GetEmployee", new { id = employee.Idemployee }, employee);
        }
Exemple #2
0
        public async Task<IActionResult> PutEmployee(long id, DBEmployee employee)
        {
            if (id != employee.Idemployee)
            {
                return BadRequest();
            }

            _context.Entry(employee).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return NoContent();
        }
Exemple #3
0
        public void Update(Employee entity)
        {
            DBEmployee dbEmpl =
                Mapper.Map <Employee, DBEmployee>(entity);

            //new DBEmployee { Email = entity.Email, FullName = entity.FullName, Id = entity.Id, Position = entity.Position, StartDate = entity.StartDate };
            DB.Employees.Update(dbEmpl);
            DB.SaveChanges();
        }
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public static List <EmployeeModel> SelectAllEmployees()
 {
     try
     {
         return(DBEmployee.SelectEmployeeAll());
     }
     catch (Exception ex)
     {
         //Log4Net
         return(null);
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="idEmployee"></param>
 /// <returns></returns>
 public static EmployeeModel SelectEmployeeById(string idEmployee)
 {
     try
     {
         string[] employee = new string[] { idEmployee };
         if (ValidateData.VerifyFields(employee))
         {
             EmployeeModel employeeModel = new EmployeeModel()
             {
                 IdEmployee = int.Parse(idEmployee),
             };
             return(DBEmployee.SelectidEmployee(employeeModel));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         //Log4Net
         return(null);
     }
 }
        public ActionResult Index()
        {
            DBEmployee db = new DBEmployee();

            return(View("Detail", db.GetDetail(1000)));
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <param name="lastName"></param>
 /// <param name="idType"></param>
 /// <param name="id"></param>
 /// <param name="residence"></param>
 /// <param name="bornDate"></param>
 /// <param name="civilState"></param>
 /// <param name="childs"></param>
 /// <param name="telephone"></param>
 /// <param name="cellphone"></param>
 /// <param name="enterStore"></param>
 /// <param name="nationality"></param>
 /// <param name="idPosition"></param>
 /// <param name="workingState"></param>
 /// <param name="enterDate"></param>
 /// <param name="endDate"></param>
 /// <param name="obervation"></param>
 /// <param name="photo"></param>
 /// <param name="nameEmergency"></param>
 /// <param name="cellphoneEmergency"></param>
 /// <returns></returns>
 public static bool InsertEmployee(
     string name,
     string lastName,
     string idType,
     string id,
     string residence,
     string bornDate,
     string civilState,
     string childs,
     string telephone,
     string cellphone,
     string enterStore,
     string nationality,
     string idPosition,
     string workingState,
     string enterDate,
     string obervation,
     byte[] photo,
     string nameEmergency,
     string cellphoneEmergency
     )
 {
     try
     {
         string[] employee = new string[] {
             name,
             lastName,
             idType,
             id,
             residence,
             bornDate,
             civilState,
             childs,
             telephone,
             cellphone,
             enterStore,
             nationality,
             idPosition,
             workingState,
             enterDate,
             obervation,
             nameEmergency,
             cellphoneEmergency
         };
         if (ValidateData.VerifyFields(employee))
         {
             EmployeeModel employeeModel = new EmployeeModel()
             {
                 Name               = name,
                 LastName           = lastName,
                 IdentificationType = idType,
                 Identification     = id,
                 Residence          = residence,
                 BornDate           = DateTime.Parse(bornDate),
                 CivilState         = civilState,
                 Childs             = childs,
                 Telephone          = telephone,
                 Cellphone          = cellphone,
                 EnterStore         = enterStore,
                 Nationality        = nationality,
                 IdPosition         = int.Parse(idPosition),
                 WorkingState       = workingState,
                 EnterDate          = DateTime.Parse(enterDate),
                 Observation        = obervation,
                 NameEmergency      = nameEmergency,
                 CellphoneEmergency = cellphoneEmergency,
                 Image              = photo
             };
             return(DBEmployee.InsertEmployee(employeeModel));
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         //Log4Net
         return(false);
     }
 }