Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,Name,CreationDate,Usercreation,StatusRegister")] Link link)
        {
            if (ModelState.IsValid)
            {
                _context.Add(link);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(link));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Cedula,Name,Phone,Movil,Email")] Propietario propietario)
        {
            if (ModelState.IsValid)
            {
                _context.Add(propietario);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(propietario));
        }
        public async Task <IActionResult> Create([Bind("Id,IdProyecto,Code,Name,StreetMain,StreetSecundary,Streetthree,Streetfour,Reference,Zona,Commentary,CreationDate,Usercreation,StatusRegister")] ZonaProspectada zonaProspectada)
        {
            if (ModelState.IsValid)
            {
                _context.Add(zonaProspectada);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdProyecto"] = new SelectList(_context.Project, "Id", "Name", zonaProspectada.IdProyecto);
            return(View(zonaProspectada));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Guardar Datos del Modelo
        /// </summary>
        /// <param name="_model">Datos de la tabla zonaprospecta</param>
        /// <returns> El resultado de la base de datos</returns>

        public int GuardarAreas_Prospeccion(ZonaProspectada _model)
        {
            try
            {
                _context.Add(_model);
                _context.Entry(_model).State = _model.Id > 0 ? EntityState.Modified : EntityState.Added;
                var get = _context.SaveChanges();
                return(get);
            }
            catch (Exception e)
            {
                string error = e.ToString();
                return(0);
            }
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,IdAccount,Code,Name,IdContry,IdProvince,IdDistrict,IdParish,IdSector,IdLink,ZonaId,Image,CreationDate,Usercreation,StatusRegister")] Project project, IFormFile upload)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    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();
                        }
                    }
                    project.CreationDate   = DateTime.Now;
                    project.StatusRegister = "A";
                    _context.Add(project);
                    await _context.SaveChangesAsync();

                    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(PartialView(project));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }