Example #1
0
        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));
        }
Example #2
0
        public void Add_OfferingIsNull_ThrowsArgumentNullException()
        {
            Offering offering = null;

            Assert.That(() => _offeringServ.Add(offering), Throws.ArgumentNullException);
        }