Ejemplo n.º 1
0
        public async Task <Employee> TerminateAsync(TerminationDetail value, Guid id) => await ManagerInvoker.Current.InvokeAsync(this, async() =>
        {
            await value.Validate().Mandatory().RunAsync(throwOnError: true).ConfigureAwait(false);

            Cleaner.CleanUp(value, id);
            await value.Validate().Entity().With <IValidator <TerminationDetail> >().RunAsync(throwOnError: true).ConfigureAwait(false);
            return(Cleaner.Clean(await _dataService.TerminateAsync(value, id).ConfigureAwait(false)));
        }, BusinessInvokerArgs.Update).ConfigureAwait(false);
Ejemplo n.º 2
0
        public Task <Employee> TerminateAsync(TerminationDetail value, Guid id)
        {
            value.Validate(nameof(value)).Mandatory().Run().ThrowOnError();

            return(ManagerInvoker.Current.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Update;
                Cleaner.CleanUp(value, id);
                value.Validate(nameof(value)).Entity(TerminationDetailValidator.Default).Run().ThrowOnError();
                return Cleaner.Clean(await _dataService.TerminateAsync(value, id).ConfigureAwait(false));
            }));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Terminates an existing employee by updating their termination columns.
        /// </summary>
        private async Task <Employee> TerminateOnImplementationAsync(TerminationDetail value, Guid id)
        {
            // Need to pre-query the data to, 1) check they exist, 2) check they are still employed, and 3) update.
            var curr = await GetOnImplementationAsync(id);

            if (curr == null)
            {
                throw new NotFoundException();
            }

            if (curr.Termination != null)
            {
                throw new ValidationException("An Employee can not be terminated more than once.");
            }

            if (value.Date < curr.StartDate)
            {
                throw new ValidationException("An Employee can not be terminated prior to their start date.");
            }

            curr.Termination = value;
            return(await UpdateOnImplementationAsync(curr));
        }
Ejemplo n.º 4
0
 public Task <WebApiAgentResult <Employee> > TerminateAsync(TerminationDetail value, Guid id, WebApiRequestOptions?requestOptions = null) =>
 PostAsync <Employee>("api/employees/{id}/terminate", Beef.Check.NotNull(value, nameof(value)), requestOptions: requestOptions,
                      args: new WebApiArg[] { new WebApiArg <Guid>("id", id) });
Ejemplo n.º 5
0
 public IActionResult Terminate([FromBody] TerminationDetail value, Guid id) =>
 new WebApiPost <Employee>(this, () => _manager.TerminateAsync(WebApiActionBase.Value(value), id),
                           operationType: OperationType.Update, statusCode: HttpStatusCode.OK, alternateStatusCode: null);