/// <summary> /// The add. /// </summary> /// <param name="owner"> /// The owner. /// </param> /// <param name="input"> /// The input. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> /// <exception cref="ArgumentNullException"> /// The argument null exception. /// </exception> /// <exception cref="Exception"> /// The exception. /// </exception> public async Task <Guid> Add(Guid owner, HumanIn input) { if (owner == null) { throw new ArgumentNullException(nameof(owner)); } if (input == null) { throw new ArgumentNullException(nameof(input)); } // TODO: Add validations var ownerExits = await this.humanRepository.ExistOwner(owner); if (!ownerExits) { throw new Exception("User doesnt exist."); } var newCode = Guid.NewGuid(); var created = await this.humanRepository.Add(owner, newCode, input); return(created != 0 ? newCode : Guid.Empty); }
public async Task <HttpResponseMessage> Edit(Guid owner, Guid human, HumanIn input) { var result = new HumanEdit { Code = human, Human = input }; return(await this.ProcessActionAsync(owner, result, this.humanService.Edit)); }
/// <summary> /// The edit. /// </summary> /// <param name="code"> /// The code. /// </param> /// <param name="input"> /// The input. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public async Task <int> Edit(Guid code, HumanIn input) { var person = new PersonEntity { Code = code, Name = input.Name, Surname = input.Surname, Email = input.Email, IsArchived = input.IsArchived }; this.context.SeedAddOrUpdate(p => p.Code, p => new { p.Name, p.Surname, p.Email, p.ChangeAt, p.IsArchived }, person); var myint = await this.context.SaveChangesAsync(); return(myint); }
/// <summary> /// The add. /// </summary> /// <param name="owner"> /// The owner. /// </param> /// <param name="code"> /// The code. /// </param> /// <param name="input"> /// The input. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public async Task <int> Add(Guid owner, Guid code, HumanIn input) { var newPerson = new PersonEntity { Code = code, OwnerCode = owner, Name = input.Name, Surname = input.Surname, Email = input.Email, IsArchived = false }; this.context.Persons.Add(newPerson); var myint = await this.context.SaveChangesAsync(); return(myint); }
/// <summary> /// The edit. /// </summary> /// <param name="code"> /// The code. /// </param> /// <param name="human"> /// The human. /// </param> /// <param name="input"> /// The input. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public Task <HttpResponseMessage> Edit(Guid code, Guid human, HumanIn input) { throw new NotImplementedException(); }
public async Task <HttpResponseMessage> Add(Guid owner, HumanIn input) { return(await this.ProcessActionAsync(owner, input, this.humanService.Add)); }