// POST: api/OfferApi public IHttpActionResult Post(Offer offer) { try { _offerAppService.Add(offer); return(Ok()); } catch (Exception e) { return(InternalServerError(e)); } }
public ActionResult Create(OfferCreateViewModel model) { try { if (!ModelState.IsValid) { model.LoadCollections(db.Colors); return(View(model)); } var offer = Mapper.Map <OfferCreateViewModel, Offer>(model); _offerAppService.Add(offer); return(RedirectToAction("Index")); } catch (Exception e) { model.LoadCollections(db.Colors); return(View(model)); } }