public async Task <Applicant> Transfer(TransferApplicantCommand command) { var applicant = await Find(command.Username); if (applicant == null) { _domainNotification.Notify(new DomainNotification("Applicant", "Not found")); return(null); } if (command.Company == applicant.CompanyId) { _domainNotification.Notify(new DomainNotification("Applicant", "Can't transfer for same company")); return(null); } if (command.Company <= 0) { _domainNotification.Notify(new DomainNotification("Applicant", "Invalid company")); return(null); } applicant.Delete(); var newApplicant = new Applicant(applicant, command.Company); await _context.AddAsync(newApplicant); await _context.SaveChangesAsync(); return(newApplicant); }
public async Task <ActionResult <Applicant> > Transfer([FromBody] TransferApplicantCommand model) { var newApplicant = await _dummyUserService.Transfer(model); return(ResponsePost(nameof(Get), new { id = newApplicant.Username }, newApplicant)); }