Exemple #1
0
        public ActionResult Create(MagazineViewModel model)
        {
            ViewBag.States = new SelectList(ResourceService.GetStates(), "StateId", "Name", model.StateId);
            ViewBag.Cities = new SelectList(ResourceService.GetCities(model.StateId), "CityId", "Name", model.CityId);

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var imageCode = "Expose_Default_Magazine.png";

            if (model.Image != null && model.Image.ContentLength > 0)
            {
                var imageModel = ResourceService.SaveImage(Server.MapPath("~/content/data/"), model.Image, false);
                if (imageModel == null)
                {
                    ModelState.AddModelError("", "No se pudo guardar la imagen. Intentalo de nuevo.");
                    return(View(model));
                }
                imageCode = imageModel.FullFileName;
            }

            var create = MagazineService.Create(model.Title, model.Description, imageCode, model.Address, model.CityId,
                                                model.Email, model.IsPrivate, model.Domain, model.FacebookAccount, model.TwitterAccount, model.GoogleAnlyticsId);

            if (create == null)
            {
                SetMessage(MagazineService.ServiceTempData);
                return(RedirectToAction("Index"));
            }

            SetMessage("Revista creada.", BootstrapAlertTypes.Success);
            return(RedirectToAction("Index"));
        }
Exemple #2
0
 public IActionResult Post([FromBody] MagazineView magazine)
 {
     if (ModelState.IsValid)
     {
         _service.Create(magazine);
         return(Ok(magazine));
     }
     return(BadRequest(ModelState));
 }
 public ActionResult Create(MagazineViewModel magazine)
 {
     if (ModelState.IsValid)
     {
         _magazineService.Create(magazine);
         return(RedirectToAction("Index"));
     }
     return(View(magazine));
 }
 public ActionResult<string> Create([FromBody] Magazine newMagazine)
 {
   try
   {
     return Ok(_ms.Create(newMagazine));
   }
   catch (Exception e)
   {
     return BadRequest(e.Message);
   }
 }//endof create
        public IHttpActionResult Add(MagazineViewModel magazineFromView)
        {
            if (magazineFromView == null || !ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var libraryStorageUnitForAdd = Mapper.Map <MagazineViewModel, LibraryStorageUnitDTO>(magazineFromView);

            var magazineForAdd = Mapper.Map <MagazineViewModel, MagazineDTO>(magazineFromView);

            magazineForAdd.Unit = libraryStorageUnitForAdd;
            _magazineService.Create(magazineForAdd);

            return(Ok(magazineFromView));
        }
        public async Task <IActionResult> Create([FromBody] CreateMagazineViewModel itemVM)
        {
            if (itemVM == null)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            int newItemId = await _service.Create(itemVM);

            itemVM.Id = newItemId;
            return(Ok(itemVM));
        }
 public IActionResult Post(GetMagazineView magazine)
 {
     magazineService.Create(magazine);
     return(Ok(magazine));
 }
Exemple #8
0
        public ActionResult AddMagazine(MagazineViewModel magazine)
        {
            magazineService.Create(magazine);

            return(Json(magazine, JsonRequestBehavior.AllowGet));
        }
Exemple #9
0
 public ActionResult Suscribete(String Email)
 {
     MagazineService.Create(Email);
     SetMessage("¡ Gracias por suscribirte ! ", BootstrapAlertTypes.Success);
     return(View());
 }