Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,CreationDate,Usercreation,StatusRegister")] Link link)
        {
            if (id != link.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(link);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LinkExists(link.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(link));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Cedula,Name,Phone,Movil,Email")] Propietario propietario)
        {
            if (id != propietario.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(propietario);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PropietarioExists(propietario.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(propietario));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,IdProyecto,Code,Name,StreetMain,StreetSecundary,Streetthree,Streetfour,Reference,Zona,Commentary,CreationDate,Usercreation,StatusRegister")] ZonaProspectada zonaProspectada)
        {
            if (id != zonaProspectada.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(zonaProspectada);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ZonaProspectadaExists(zonaProspectada.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdProyecto"] = new SelectList(_context.Project, "Id", "Name", zonaProspectada.IdProyecto);
            return(View(zonaProspectada));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,IdAccount,Code,Name,IdContry,IdProvince,IdDistrict,IdParish,IdSector,IdLink,ZonaId,CreationDate,Usercreation,StatusRegister")] Project project)
        {
            if (id != project.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var projectactual = _context.Project.Where(m => m.Id == id).FirstOrDefault();

                    var files = Request.Form.Files;
                    if (files.Count > 0)
                    {
                        var imagenarchivo = files[0];
                        var filePath      = Path.GetTempFileName();

                        using (var stream = new MemoryStream())
                        {
                            await imagenarchivo.CopyToAsync(stream);

                            project.Image       = stream.ToArray();
                            projectactual.Image = project.Image;
                        }
                    }
                    else
                    {
                        if (ViewBag.imagenactual != null)
                        {
                            project.Image = ViewBag.imagenactual;
                        }
                    }


                    projectactual.CreationDate = DateTime.Now;
                    projectactual.IdAccount    = project.IdAccount;
                    projectactual.Name         = project.Name;
                    projectactual.IdContry     = project.IdContry;
                    projectactual.IdProvince   = project.IdProvince;
                    projectactual.IdDistrict   = project.IdDistrict;
                    projectactual.IdParish     = project.IdParish;
                    projectactual.IdSector     = project.IdSector;
                    projectactual.IdLink       = project.IdLink;
                    projectactual.ZonaId       = project.ZonaId;
                    projectactual.Usercreation = User.Identity.Name.ToString();
                    //projectactual.StatusRegister = project.StatusRegister;
                    _context.Update(projectactual);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProjectExists(project.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdAccount"]  = new SelectList(_context.Account, "Id", "Name", project.IdAccount);
            ViewData["IdContry"]   = new SelectList(_context.Country, "Id", "Name", project.IdContry);
            ViewData["IdDistrict"] = new SelectList(_context.District, "Id", "Name", project.IdDistrict);
            ViewData["IdLink"]     = new SelectList(_context.Link, "Id", "Name", project.IdLink);
            ViewData["IdParish"]   = new SelectList(_context.Parish, "Id", "Name", project.IdParish);
            ViewData["IdProvince"] = new SelectList(_context.Province, "Id", "Name", project.IdProvince);
            ViewData["IdSector"]   = new SelectList(_context.Sector, "Id", "Name", project.IdSector);
            ViewData["ZonaId"]     = new SelectList(_context.Zona, "Id", "Name", project.ZonaId);
            return(View(project));
        }