public ActionResult Create(Especialidade p, HttpPostedFileBase file) { try { if (ModelState.IsValid) { List <Caracteristica> l = p.Caracteristicas.Where(c => c.Texto != null).ToList(); p.Caracteristicas = l; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName); file.SaveAs(path); p.Fotografia = file.FileName; //p.Fotografia = path; } db.Especialidades.Add(p); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } PopulateEstabelecimentosDropDownList(p.EstabelecimentoID); PopulatePetiscosDropDownList(p.PetiscoID); return(View(p)); }
public ActionResult Create(Petisco p) { try { if (ModelState.IsValid) { db.Petiscos.Add(p); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(p)); }
public PublicServiceControllerTests() { var dbContextOptions = CreateDbContext(); _existingPublicServiceId = "DVR000000001"; var publicServiceListItem = new PublicServiceListItem { PublicServiceId = _existingPublicServiceId, Name = "Dienstverlening" }; _backofficeContext = new BackofficeContext(dbContextOptions); _backofficeContext.PublicServiceList.Add(publicServiceListItem); _backofficeContext.SaveChanges(); _eventMapping = new EventMapping(EventMapping.DiscoverEventNamesInAssembly(typeof(DomainAssemblyMarker).Assembly)); _eventDeserializer = new EventDeserializer(JsonConvert.DeserializeObject); }