Ejemplo n.º 1
0
        public ActionResult Add(Place place/*, HttpPostedFileBase uploadedFile*/, [ModelBinder(typeof(UserIdBinder))] int userId)
        {
            if (!ModelState.IsValid)
            {
                return View(place);
            }
            
            //if (uploadedFile != null && uploadedFile.ContentLength > 0)
            //{
            //    var target = new MemoryStream();
            //    uploadedFile.InputStream.CopyTo(target);
            //    place.PhotoFile = target.ToArray();
            //}

            try
            {
                place.UserId = userId;
                _unitOfWork.Places.Insert(place);
                _unitOfWork.Save();

                TempData.AddAlertSuccess("Place has been added!");
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex);
            }
            
            return RedirectToAction("List");
        }
Ejemplo n.º 2
0
        public ActionResult Add()
        {
            var place = new Place();
            place.Link = "http://www";

            return View(place);
        }