public Avatar Delete(int id) { if (id < 1) { throw new InvalidDataException("Id must be atleast 1"); } return(_aRepo.Delete(id)); }
public Avatar Delete(Avatar avatar) { if (avatar.Id < 1) { throw new InvalidDataException("Id must be atleast 1"); } return(_aRepo.Delete(avatar)); }
public async Task <IHttpActionResult> Delete() { try { var avatarIdString = HttpContext.Current.Request.Form.Get("avatarId"); if (string.IsNullOrWhiteSpace(avatarIdString)) { return(BadRequest("Avatar id is empty")); } if (!int.TryParse(avatarIdString, out int avatarId)) { return(BadRequest("Avatar id is not a valid number")); } if (avatarId == 0) { return(BadRequest("Avatar provided is empty")); } var deleted = await _avatarRepository.Delete(avatarId); if (!deleted) { return(BadRequest($"Avatar with id {avatarId} couldn't be deleted")); } return(Ok(true)); } catch (Exception e) { Console.WriteLine(e); #if DEBUG return(InternalServerError(e)); #else return(InternalServerError()); #endif } }
public Avatar DeleteAvatar(int id) { return(_avatarRepo.Delete(id)); }