Ejemplo n.º 1
0
        public async Task <IActionResult> Create(EmployeeAttendCMV employeeAttendCMV)
        {
            if (ModelState.IsValid)
            {
                var attend   = _mapper.Map <Attend>(employeeAttendCMV);
                var contract = await _repository.GetEmployeeContractByEmpId(employeeAttendCMV.EmployeeId);

                attend.EmployeeContractId = contract.Id;
                attend.WorkingHours       = contract.DailyWorkingHours;
                attend.AppUserId          = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
                _repository.Add <Attend>(attend);
                await _repository.SavaAll();

                return(RedirectToAction(nameof(Index)).WithSuccess("success", "تم الحفظ بنجاح"));
            }
            ViewData["TheWork"]    = new SelectList(TheWorName(), "ThWork", "ThWork", employeeAttendCMV.TheWork);
            ViewData["EmployeeId"] = new SelectList(await _repository.GetEmployeeContractActive(), "Id", "Name", employeeAttendCMV.EmployeeId);
            return(View());
        }