public async Task <IActionResult> PutBehavioralType([FromRoute] int id, [FromBody] BehavioralType behavioralType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != behavioralType.TypeId) { return(BadRequest()); } try { await behavioralTypesService.Update(id, behavioralType); } catch (DbUpdateConcurrencyException) { if (!BehavioralTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <BehavioralType> Delete(int id) { try { BehavioralType objBehavioralType = new BehavioralType(); objBehavioralType = await context.TblType.SingleOrDefaultAsync(a => a.TypeId == id); //objBehavioralType.IsDeleted = true; //objBehavioralType.DeletedBy = id; //objBehavioralType.DeletedDate = DateTime.Now; if (objBehavioralType == null) { throw new InvalidOperationException(); } context.TblType.Update(objBehavioralType); await context.SaveChangesAsync(); return(objBehavioralType); } catch (Exception) { throw; } }
public async Task <BehavioralType> Insert(BehavioralType tblBehavioralType) { try { context.Add(tblBehavioralType); await context.SaveChangesAsync(); return(tblBehavioralType); } catch (Exception) { throw; } }
public async Task <IActionResult> PostBehavioralType([FromBody] BehavioralType behavioralType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var entity = await behavioralTypesService.Insert(behavioralType); if (entity == null) { return(BadRequest()); } return(CreatedAtAction("GetBehavioralTypeByID", new { id = behavioralType.TypeId }, behavioralType)); }
public async Task Update(int Id, BehavioralType tblBehavioralType) { try { if (tblBehavioralType == null) { throw new ArgumentNullException(nameof(tblBehavioralType)); } if (Id != tblBehavioralType.TypeId) { throw new NotImplementedException(); } context.TblType.Update(tblBehavioralType); await context.SaveChangesAsync(); } catch (Exception) { throw; } }