예제 #1
0
 public Avatar Delete(int id)
 {
     if (id < 1)
     {
         throw new InvalidDataException("Id must be atleast 1");
     }
     return(_aRepo.Delete(id));
 }
예제 #2
0
 public Avatar Delete(Avatar avatar)
 {
     if (avatar.Id < 1)
     {
         throw new InvalidDataException("Id must be atleast 1");
     }
     return(_aRepo.Delete(avatar));
 }
예제 #3
0
        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
            }
        }
예제 #4
0
 public Avatar DeleteAvatar(int id)
 {
     return(_avatarRepo.Delete(id));
 }