public async Task <IHttpActionResult> CreateBid([FromBody] BidDTO bid) { if (bid == null) { return(BadRequest()); } var UserName = this.User.Identity.Name; var user = await _userService.FindByNameAsync(UserName); if (user == null) { return(NotFound()); } bid.UserId = user.Id; bid.MadeOn = DateTime.Now; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { await _bidService.CreateAsync(bid); } catch (ArgumentException e) { return(BadRequest(e.Message)); } catch (Exception e) { return(BadRequest(e.Message)); } return(StatusCode(HttpStatusCode.Created)); }