public async Task ValidateNoVessels(IBodyContainer bodyContainer) { if (await Context.Vessel.FirstOrDefaultAsync(v => v.BodyName == bodyContainer.BodyName) != null) { throw new Exception($"Body {bodyContainer.BodyName} has vessels!"); } }
private async Task <BodyEntity> Get(IBodyContainer body) { if (body == null) { throw new ArgumentNullException("Body is null"); } return(await Context.Body.Include(b => b.Vessel).FirstOrDefaultAsync(b => b.BodyName == body.BodyName)); }
public async Task <Body> DeleteAsync(IBodyContainer body) { await ValidateNoVessels(body); var entity = Context.Body.Remove(await Get(body)).Entity; await Context.SaveChangesAsync(); return(Mapper.Map <Body>(entity)); }
public async Task ValidateAsync(IBodyContainer bodyContainer) { if (bodyContainer == null) { throw new ArgumentNullException("Body Container is null"); } Body body = await Get(bodyContainer); if (bodyContainer.BodyName != null && body == null) { throw new InvalidOperationException("No body with name " + bodyContainer.BodyName); } }
public Task <Body> Delete(IBodyContainer bodyId) { return(BodyDataAccess.DeleteAsync(bodyId)); }
public Task <Body> Read(IBodyContainer bodyId) { return(BodyDataAccess.GetAsync(bodyId)); }
/// <summary> /// Initializes a new body for the given love. /// </summary> /// <param name="parent">The parent truth.</param> /// <param name="loveId">The id of the love the body is for.</param> public Body(IBodyContainer parent, int loveId = -1) { this.m_Parent = parent; this.m_LoveId = loveId; this.BodyType = BodyType.Left; }
public async Task <Body> GetAsync(IBodyContainer bodyContainer) { return(bodyContainer.BodyName != null?Mapper.Map <Body>(await Get(bodyContainer)) : null); }
private async Task <Body> Get(IBodyContainer bodyContainer) { return(await BodyDataAccess.GetAsync(bodyContainer)); }