public async Task <bool> Handle(CreateLeaveCommand request, CancellationToken cancellationToken) { // Add/Update the Leave AggregateRoot // DDD patterns comment: Add child entities and value-objects through the Order Aggregate-Root // methods and constructor so validations, invariants and business logic // make sure that consistency is preserved across the whole aggregate // Recupera el los LeaveType para comprobar que es un ID correcto, se ha hecho solo a modo de ejemplo, se podría hacer lo mismo para el ResourceId LeaveReason leaveReason = new LeaveReason(request.LeaveReason.Name, request.LeaveReason.Description); var leaveTypes = await _leaveQueries.GetLeaveTypesAsync(); var selectedType = leaveTypes.Where(x => x.Id == request.LeaveTypeId).FirstOrDefault(); if (selectedType != null) { var leave = new Leave(request.IdUser, request.UserName, leaveReason, request.DateStart, request.DateEnd, request.Comments, request.LeaveTypeId, request.ResourceId); //_logger.LogInformation("----- Creating Order - Order: {@Order}", order); _leaveRepository.Add(leave); return(await _leaveRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken)); } return(false); }
public virtual ActionResult CreateLeave(Leave leave) { leave.IsActive = true; _leaveRepository.Add(leave); _unitOfWork.Commit(); return(RedirectToAction("Leave")); }
public bool Add(LeaveAddRequest newLeave) { try { return(_leaveRepository.Add(newLeave)); } catch (Exception ex) { throw ex; } }
public bool SaveLeave(Leave leave) { if (leave.LeaveId > 0) { leaveRepository.Update(leave); } else { leaveRepository.Add(leave); } return(true); }
public RedirectToActionResult Create(Leave employee) { Leave newEmployee = new Leave { LeaveId = employee.LeaveId, Type = employee.Type, FromDate = employee.FromDate, ToDate = employee.ToDate, EmployeeName = employee.EmployeeName }; _empRepo.Add(newEmployee); return(RedirectToAction("AllDetails")); }
public bool CreateLeave(Leave leave) { bool isSuccess = true; try { leaveRepository.Add(leave); this.SaveRecord(); ServiceUtil <Leave> .WriteActionLog(leave.Id, ENUMOperation.CREATE, leave); } catch (Exception ex) { isSuccess = false; logger.Error("Error in creating Leave", ex); } return(isSuccess); }
/// <summary> /// Adds a new Leave /// </summary> /// <param name="Leave">Leave details object</param> /// <returns>Returns true</returns> public bool AddLeave(Leave Leave) { _leaveRepository.Add(Leave); return(true); }