public ActionResult Create(Zapateria zapateria) { var user = db.Owners.Where(u => u.Email == User.Identity.Name).FirstOrDefault(); if (ModelState.IsValid) { zapateria.OwnerId = user.OwnerId; db.Zapaterias.Add(zapateria); var response = DbHelper.SaveChanges(db); if (zapateria.LogoFile != null) { var folder = "~/Content/Logos"; var file = string.Format("{0}{1}.jpg", zapateria.ZapateriaId, zapateria.Name); var responsefile = FileHelper.UploadPhoto(zapateria.LogoFile, folder, file); if (responsefile) { var pic = string.Format("{0}/{1}", folder, file); zapateria.Logo = pic; db.Entry(zapateria).State = EntityState.Modified; db.SaveChanges(); } } if (response.Successfully) { DbHelper.InsertBitacora("Create", "Zapaterias", User.Identity.Name, db); return(RedirectToAction("Index")); } ModelState.AddModelError(string.Empty, response.Message); } ViewBag.IdColony = new SelectList(CombosHelper.GetColonies(zapateria.IdColony), "IdColony", "Description", zapateria.IdColony); ViewBag.IdMunicipality = new SelectList(CombosHelper.GetMunicipalities(zapateria.IdMunicipality), "IdMunicipality", "Description", zapateria.IdMunicipality); ViewBag.IdState = new SelectList(CombosHelper.GetStates(), "IdState", "Description", zapateria.IdState); return(View(zapateria)); }
// GET: Administrators/Create public ActionResult Create() { ViewBag.IdColony = new SelectList(CombosHelper.GetColonies(0), "IdColony", "Description"); ViewBag.IdMunicipality = new SelectList(CombosHelper.GetMunicipalities(0), "IdMunicipality", "Description"); ViewBag.IdState = new SelectList(CombosHelper.GetStates(), "IdState", "Description"); return(View()); }
public ActionResult Create(Administrator administrator) { if (ModelState.IsValid) { db.Administrators.Add(administrator); var response = DbHelper.SaveChanges(db); UsersHelper.CreateUserASP(administrator.Email, "Admin", administrator.Password); if (administrator.PhotoFile != null) { var folder = "~/Content/Photos"; var file = string.Format("{0}{1}.jpg", administrator.AdministratorId, administrator.FirstName); var responsefile = FileHelper.UploadPhoto(administrator.PhotoFile, folder, file); if (responsefile) { var pic = string.Format("{0}/{1}", folder, file); administrator.Photo = pic; db.Entry(administrator).State = EntityState.Modified; db.SaveChanges(); } } if (response.Successfully) { return(RedirectToAction("Index")); } ModelState.AddModelError(string.Empty, response.Message); } ViewBag.IdColony = new SelectList(CombosHelper.GetColonies(administrator.ColonyId), "IdColony", "Description", administrator.ColonyId); ViewBag.IdMunicipality = new SelectList(CombosHelper.GetMunicipalities(administrator.MunicipalityId), "IdMunicipality", "Description", administrator.MunicipalityId); ViewBag.IdState = new SelectList(CombosHelper.GetStates(), "IdState", "Description", administrator.StateId); return(View(administrator)); }
public ActionResult Create(Owner owner) { if (ModelState.IsValid) { db.Owners.Add(owner); var response = DbHelper.SaveChanges(db); UsersHelper.CreateUserASP(owner.Email, "Owner", owner.Password); if (owner.PhotoFile != null) { var folder = "~/Content/Photo"; var file = string.Format("{0}{1}.jpg", owner.OwnerId, owner.FirstName); var responsefile = FileHelper.UploadPhoto(owner.PhotoFile, folder, file); if (responsefile) { var pic = string.Format("{0}/{1}", folder, file); owner.Photo = pic; db.Entry(owner).State = EntityState.Modified; RegisterUser(owner); db.SaveChanges(); } } if (response.Successfully) { DbHelper.InsertBitacora("Create", "Owners", User.Identity.Name, db); return(RedirectToAction("Message")); } ModelState.AddModelError(string.Empty, response.Message); } ViewBag.IdColony = new SelectList(CombosHelper.GetColonies(owner.IdColony), "IdColony", "Description", owner.IdColony); ViewBag.IdMunicipality = new SelectList(CombosHelper.GetMunicipalities(owner.IdMunicipality), "IdMunicipality", "Description", owner.IdMunicipality); ViewBag.IdState = new SelectList(CombosHelper.GetStates(), "IdState", "Description", owner.IdState); return(View(owner)); }
public ActionResult Create() { ViewBag.CategoryId = new SelectList(CombosHelper.GetCategories(), "CategoryId", "Description"); ViewBag.ColonyId = new SelectList(CombosHelper.GetColonies(0), "ColonyId", "Description"); ViewBag.MunicipalityId = new SelectList(CombosHelper.GetMunicipalities(0), "MunicipalityId", "Description"); ViewBag.StateId = new SelectList(CombosHelper.GetStates(), "StateId", "Description"); return(View()); }
// GET: Zapaterias/Create public ActionResult Create() { var user = db.Owners.Where(u => u.Email == User.Identity.Name).FirstOrDefault(); ViewBag.IdColony = new SelectList(CombosHelper.GetColonies(0), "IdColony", "Description"); ViewBag.IdMunicipality = new SelectList(CombosHelper.GetMunicipalities(0), "IdMunicipality", "Description"); ViewBag.IdState = new SelectList(CombosHelper.GetStates(), "IdState", "Description"); var zapateria = new Zapateria { OwnerId = user.OwnerId }; return(View(zapateria)); }
public ActionResult Edit(Colony colony) { if (ModelState.IsValid) { db.Entry(colony).State = EntityState.Modified; var response = DbHelper.SaveChanges(db); if (response.Successfully) { return(RedirectToAction("Index")); } ModelState.AddModelError(string.Empty, response.Message); } ViewBag.IdMunicipality = new SelectList(CombosHelper.GetMunicipalities(), "IdMunicipality", "Description", colony.IdMunicipality); return(View(colony)); }
// GET: Colonies/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Colony colony = db.Colonies.Find(id); if (colony == null) { return(HttpNotFound()); } ViewBag.IdMunicipality = new SelectList(CombosHelper.GetMunicipalities(), "IdMunicipality", "Description", colony.IdMunicipality); return(View(colony)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var administrator = db.Administrators.Find(id); if (administrator == null) { return(HttpNotFound()); } ViewBag.IdColony = new SelectList(CombosHelper.GetColonies(0), "IdColony", "Description", administrator.ColonyId); ViewBag.IdMunicipality = new SelectList(CombosHelper.GetMunicipalities(0), "IdMunicipality", "Description", administrator.MunicipalityId); ViewBag.IdState = new SelectList(CombosHelper.GetStates(), "IdState", "Description", administrator.StateId); return(View(administrator)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Owner owner = db.Owners.Find(id); if (owner == null) { return(HttpNotFound()); } ViewBag.IdColony = new SelectList(CombosHelper.GetColonies(), "IdColony", "Description", owner.IdColony); ViewBag.IdMunicipality = new SelectList(CombosHelper.GetMunicipalities(), "IdMunicipality", "Description", owner.IdMunicipality); ViewBag.IdState = new SelectList(CombosHelper.GetStates(), "IdState", "Description", owner.IdState); return(View(owner)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RequestInstitute requestInstitute = db.RequestInstitutes.Find(id); if (requestInstitute == null) { return(HttpNotFound()); } ViewBag.CategoryId = new SelectList(CombosHelper.GetCategories(), "CategoryId", "Description", requestInstitute.CategoryId); ViewBag.ColonyId = new SelectList(CombosHelper.GetColonies(0), "ColonyId", "Description", requestInstitute.ColonyId); ViewBag.MunicipalityId = new SelectList(CombosHelper.GetMunicipalities(0), "MunicipalityId", "Description", requestInstitute.MunicipalityId); ViewBag.StateId = new SelectList(CombosHelper.GetStates(), "StateId", "Description", requestInstitute.StateId); return(View(requestInstitute)); }
public ActionResult Edit(RequestInstitute requestInstitute) { if (ModelState.IsValid) { db.Entry(requestInstitute).State = EntityState.Modified; var response = DbHelper.SaveChanges(db); if (response.Successfully) { return(RedirectToAction("Index")); } ModelState.AddModelError(string.Empty, response.Message); } ViewBag.CategoryId = new SelectList(CombosHelper.GetCategories(), "CategoryId", "Description", requestInstitute.CategoryId); ViewBag.ColonyId = new SelectList(CombosHelper.GetColonies(requestInstitute.ColonyId), "ColonyId", "Description", requestInstitute.ColonyId); ViewBag.MunicipalityId = new SelectList(CombosHelper.GetMunicipalities(requestInstitute.MunicipalityId), "MunicipalityId", "Description", requestInstitute.MunicipalityId); ViewBag.StateId = new SelectList(CombosHelper.GetStates(), "StateId", "Description", requestInstitute.StateId); return(View(requestInstitute)); }
public ActionResult Create(RequestInstitute requestInstitute) { if (ModelState.IsValid) { requestInstitute.SendDate = DateTime.Now; requestInstitute.Status = "Espera"; db.RequestInstitutes.Add(requestInstitute); var response = DbHelper.SaveChanges(db); if (response.Successfully) { return(RedirectToAction("Mensaje")); } ModelState.AddModelError(string.Empty, response.Message); } ViewBag.CategoryId = new SelectList(CombosHelper.GetCategories(), "CategoryId", "Description", requestInstitute.CategoryId); ViewBag.ColonyId = new SelectList(CombosHelper.GetColonies(requestInstitute.ColonyId), "ColonyId", "Description", requestInstitute.ColonyId); ViewBag.MunicipalityId = new SelectList(CombosHelper.GetMunicipalities(requestInstitute.MunicipalityId), "MunicipalityId", "Description", requestInstitute.MunicipalityId); ViewBag.StateId = new SelectList(CombosHelper.GetStates(), "StateId", "Description", requestInstitute.StateId); return(View(requestInstitute)); }