public IHttpActionResult Post(OfferingDto form) { if (ModelState.IsValid) { try { var offering = Mapper.Map <OfferingDto, Offering>(form); _offeringService.Add(offering); var offeringDto = GetOfferingDto(offering); return(Created(new Uri(offeringDto.Url), offeringDto)); } catch (ArgumentException ae) { ModelState.AddModelError("", ae.Message); } catch (PreexistingEntityException pe) { ModelState.AddModelError("", pe.Message); } } return(BadRequest(ModelState)); }
public void Add_OfferingIsNull_ThrowsArgumentNullException() { Offering offering = null; Assert.That(() => _offeringServ.Add(offering), Throws.ArgumentNullException); }