public async Task SaveRespuestaCuestionario(RespuestaCuestionario respuestaCuestionario)
 {
     respuestaCuestionario.Activo = 1;
     respuestaCuestionario.Fecha  = DateTime.Now;
     _context.Add(respuestaCuestionario);
     await _context.SaveChangesAsync();
 }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Email,Password,ConfirmPassword,CreateDate,CreateBy,UpdateDate,UpdateBy")] User user)
        {
            Security.LoginCheck(HttpContext);
            if (ModelState.IsValid)
            {
                user.UpdateDate = DateTime.Now;
                user.UpdateBy   = User.Identity.Name;
                user.Password   = Convert.ToBase64String(SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(user.Password)));
                try
                {
                    _context.Add(user);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                catch (ArgumentException ex)
                {
                    //argument hatasından burası calısır.
                    ModelState.AddModelError("Email", "Bu eposta adresi daha önce kullanılmış.");
                }
                catch (Exception ex)
                {
                    //genel herhangibir hata olursa burası calısır argument hatası harıcınde
                }
                finally
                {
                    //her zaman calısır. hata olmasa bile.
                }
            }
            return(View(user));
        }
        public async Task <IActionResult> Create([Bind("Id,Upload,Photo,ProductId")] BigSizePhoto bigsizePhoto)
        {
            if (bigsizePhoto.Upload == null)
            {
                ModelState.AddModelError("Upload", "The Photo field is required.");
            }
            else
            {
                if (bigsizePhoto.Upload.ContentType != "image/jpeg" && bigsizePhoto.Upload.ContentType != "image/png" && bigsizePhoto.Upload.ContentType != "image/gif")
                {
                    ModelState.AddModelError("Upload", "You can only download png, jpg or gif file");
                }

                if (bigsizePhoto.Upload.Length > 1048576)
                {
                    ModelState.AddModelError("Upload", "The file size can be a maximum of 1 MB");
                }
            }
            if (ModelState.IsValid)
            {
                var fileName = _fileManager.Upload(bigsizePhoto.Upload);
                bigsizePhoto.Photo = fileName;

                _context.Add(bigsizePhoto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", bigsizePhoto.ProductId);

            return(View(bigsizePhoto));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Upload,Photo,Id")] AboutChooseUs aboutChooseUs)
        {
            if (aboutChooseUs.Upload == null)
            {
                ModelState.AddModelError("Upload", "Şəkil məcburidir");
            }
            else
            {
                if (aboutChooseUs.Upload.ContentType != "image/jpeg" && aboutChooseUs.Upload.ContentType != "image/png" && aboutChooseUs.Upload.ContentType != "image/gif")
                {
                    ModelState.AddModelError("Upload", "Siz yalnız png,jpg və ya gif faylı yükləyə bilərsiniz");
                }

                if (aboutChooseUs.Upload.Length > 1048576)
                {
                    ModelState.AddModelError("Upload", "Fayl ölcüsu maximum 1MB ola bilər");
                }
            }
            if (ModelState.IsValid)
            {
                var fileName = _fileManager.Upload(aboutChooseUs.Upload);
                aboutChooseUs.Photo = fileName;

                _context.Add(aboutChooseUs);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(aboutChooseUs));
        }
Exemplo n.º 5
0
        public ActionResult Post(long accion, [FromBody] Cliente usuario)
        {
            Encriptar encriptar = new Encriptar();

            if (accion == 0)
            {
                try
                {
                    String consena = encriptar.SHA256_Certificado(usuario.Pass);
                    usuario.Pass    = consena;
                    usuario.Usuario = usuario.Usuario.ToUpper();
                    _context.Add(usuario);
                    _context.SaveChanges();
                    return(Ok(usuario.Id));
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex.Message));
                }
            }
            else
            {
                Put(accion, usuario);
                return(Ok());
            }
        }
        public async Task <IActionResult> Create([Bind("FullName,Upload,Photo,Id,Profession,Description")] HomeTestimonial homeTestimonial)
        {
            if (homeTestimonial.Upload == null)
            {
                ModelState.AddModelError("Upload", "Şəkil məcburidir");
            }
            else
            {
                if (homeTestimonial.Upload.ContentType != "image/jpeg" && homeTestimonial.Upload.ContentType != "image/png" && homeTestimonial.Upload.ContentType != "image/gif")
                {
                    ModelState.AddModelError("Upload", "Siz yalnız png,jpg və ya gif faylı yükləyə bilərsiniz");
                }

                if (homeTestimonial.Upload.Length > 1048576)
                {
                    ModelState.AddModelError("Upload", "Fayl ölcüsu maximum 1MB ola bilər");
                }
            }
            if (ModelState.IsValid)
            {
                var fileName = _fileManager.Upload(homeTestimonial.Upload);
                homeTestimonial.Photo = fileName;

                _context.Add(homeTestimonial);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(homeTestimonial));
        }
        public async Task <IActionResult> Create([Bind("Title,Upload,Photo,Id,Content,Description,Link,TextStyleLeft,TextStyleRight,Status")] FashionSlider fashion)
        {
            if (fashion.Upload == null)
            {
                ModelState.AddModelError("Upload", "The Photo field is required.");
            }
            else
            {
                if (fashion.Upload.ContentType != "image/jpeg" && fashion.Upload.ContentType != "image/png" && fashion.Upload.ContentType != "image/gif")
                {
                    ModelState.AddModelError("Upload", "You can only download png, jpg or gif file");
                }

                if (fashion.Upload.Length > 1048576)
                {
                    ModelState.AddModelError("Upload", "The file size can be a maximum of 1 MB");
                }
            }
            if (ModelState.IsValid)
            {
                var fileName = _fileManager.Upload(fashion.Upload);
                fashion.Photo = fileName;

                _context.Add(fashion);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(fashion));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("Name,Upload,Photo,Id,ProductCount")] Kapee.Models.Category.Category category)
        {
            if (category.Upload == null)
            {
                ModelState.AddModelError("Upload", "The Photo field is required.");
            }
            else
            {
                if (category.Upload.ContentType != "image/jpeg" && category.Upload.ContentType != "image/png" && category.Upload.ContentType != "image/gif")
                {
                    ModelState.AddModelError("Upload", "You can only download png, jpg or gif file");
                }

                if (category.Upload.Length > 1048576)
                {
                    ModelState.AddModelError("Upload", "The file size can be a maximum of 1 MB");
                }
            }
            if (ModelState.IsValid)
            {
                var fileName = _fileManager.Upload(category.Upload);
                category.Photo = fileName;

                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
        public async Task <IActionResult> Create([Bind("Title,Upload,Photo,Id")] TestimonialItem testimonial)
        {
            if (testimonial.Upload == null)
            {
                ModelState.AddModelError("Upload", "The Photo field is required.");
            }
            else
            {
                if (testimonial.Upload.ContentType != "image/jpeg" && testimonial.Upload.ContentType != "image/png" && testimonial.Upload.ContentType != "image/gif")
                {
                    ModelState.AddModelError("Upload", "You can only download png, jpg or gif file");
                }

                if (testimonial.Upload.Length > 1048576)
                {
                    ModelState.AddModelError("Upload", "The file size can be a maximum of 1 MB");
                }
            }
            if (ModelState.IsValid)
            {
                var fileName = _fileManager.Upload(testimonial.Upload);
                testimonial.Photo = fileName;

                _context.Add(testimonial);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(testimonial));
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("Id,Title,Description,Photo,PublishDate,IsPublished,CreateDate,CreatedBy,UpdateDate,UpdatedBy,CategoryId")] News news, IFormFile upload)
        {
            //dosya uzantısı ıcın gecerliik denetimi
            if (upload != null && !IsExtensionValid(upload))
            {
                ModelState.AddModelError("Photo", "Dosya uzantısı jpg, jpeg ,gif , png olmalıdır.");
            }
            else if (upload == null)
            {
                ModelState.AddModelError("Photo", "Resim yüklemeniz gerekmektedir");
            }

            if (ModelState.IsValid)
            {
                news.CreateDate  = DateTime.Now;
                news.CreatedBy   = User.Identity.Name;
                news.UpdateDate  = DateTime.Now;
                news.UpdatedBy   = User.Identity.Name;
                news.PublishDate = DateTime.Now;

                //dosya yuklemesi
                if (upload != null && upload.Length > 0 && IsExtensionValid(upload))
                {
                    news.Photo = await UploadFileAsync(upload);
                }

                _context.Add(news);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", news.CategoryId);
            return(View(news));
        }
Exemplo n.º 11
0
        public async Task <ActionResult> Post([FromBody] GeneroCreacionDTO generoCreacionDTO)
        {
            var genero = mapper.Map <Genero>(generoCreacionDTO);

            context.Add(genero);
            await context.SaveChangesAsync();

            return(NoContent());
        }
Exemplo n.º 12
0
        public ActionResult Post(long accion, [FromBody] Cuenta cuenta)
        {
            if (accion == 0)
            {
                try
                {
                    _context.Add(cuenta);
                    _context.SaveChanges();
                    return(Ok());
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex.Message));
                }
            }
            else if (accion == 1)
            {
                AplicationDbContext db = new AplicationDbContext();
                var consulta           = from c in db.Cuentas
                                         where cuenta.Id == c.Id
                                         select c;

                foreach (var c in consulta)
                {
                    cuenta.Monto = cuenta.Monto + c.Monto;
                }

                Put(cuenta.Id, cuenta);
                return(Ok());
            }
            else
            {
                AplicationDbContext db = new AplicationDbContext();
                var consulta           = from c in db.Cuentas
                                         where cuenta.Id == c.Id
                                         select c;
                long antescuent = 0;
                long nueva      = 0;
                foreach (var c in consulta)
                {
                    antescuent = c.Monto;
                    nueva      = c.Monto - cuenta.Monto;
                    if (nueva < 0)
                    {
                        return(BadRequest("Valor insuficiente"));
                    }
                    else
                    {
                        cuenta.Monto = nueva;
                    }
                }

                Put(cuenta.Id, cuenta);
                return(Ok());
            }
        }
Exemplo n.º 13
0
        public async Task <IActionResult> Create([Bind("Id,Facebook,Twitter,Linkedin,Yotube")] SocialLink socialLink)
        {
            if (ModelState.IsValid)
            {
                _context.Add(socialLink);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(socialLink));
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Content")] AboutChooseUsItem aboutChooseUsItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(aboutChooseUsItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(aboutChooseUsItem));
        }
        public async Task <IActionResult> Create([Bind("Id,Nombre")] ResponsableZonal responsableZonal)
        {
            if (ModelState.IsValid)
            {
                _context.Add(responsableZonal);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(responsableZonal));
        }
Exemplo n.º 16
0
        public async Task <IActionResult> Create([Bind("Id,ProductName,Price,Category,Unidad,Fecha_Registro,Path_Imagen")] Producto producto)
        {
            if (ModelState.IsValid)
            {
                _context.Add(producto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(producto));
        }
Exemplo n.º 17
0
        public IActionResult Novo(Atracoes atracoes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(atracoes);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View());
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Content,Text")] HomeSpecialitySucces homeSuccess)
        {
            if (ModelState.IsValid)
            {
                _context.Add(homeSuccess);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(homeSuccess));
        }
        public async Task <IActionResult> Create([Bind("IdCli,Nome,Cpf,Contrato,Data,Valor_principal,Valor_atualizado")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cliente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
        public IActionResult Novo(Hospedagem hospedagem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hospedagem);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View());
        }
Exemplo n.º 21
0
        public async Task <IActionResult> Create([Bind("Id,Nombre,Apellido,Direccion")] Clientes clientes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clientes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(clientes));
        }
Exemplo n.º 22
0
        public async Task <IActionResult> Create([Bind("Id,Address,Phone,Email")] Setting setting)
        {
            if (ModelState.IsValid)
            {
                _context.Add(setting);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(setting));
        }
        public async Task <IActionResult> Create([Bind("IdPagto,IdCli,Cpf,Contrato,Parcela,Data,Valor,Desconto,Situacao")] Pagamento pagamento)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pagamento);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCli"] = new SelectList(_context.Cliente, "IdCli", "IdCli", pagamento.IdCli);
            return(View(pagamento));
        }
Exemplo n.º 24
0
        public async Task <IActionResult> Create([Bind("Id,Title,Content,Icon")] Info info)
        {
            if (ModelState.IsValid)
            {
                _context.Add(info);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(info));
        }
Exemplo n.º 25
0
        public async Task <IActionResult> Create([Bind("Id,Capital,Intereses,Periodo,ClientesId")] Prestamo prestamo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(prestamo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClientesId"] = new SelectList(_context.Clientes, "Id", "Apellido", prestamo.ClientesId);
            return(View(prestamo));
        }
Exemplo n.º 26
0
 public ActionResult Post([FromBody] Comentario comentario)
 {
     try
     {
         _context.Add(comentario);
         _context.SaveChanges();
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 27
0
        public async Task <IActionResult> Create([Bind("Id,Name,CategoryId")] SubCategory subCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(subCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", subCategory.CategoryId);

            return(View(subCategory));
        }
Exemplo n.º 28
0
        public ActionResult Post([FromBody] employees empleados)
        {
            try
            {
                _context.Add(empleados);
                _context.SaveChanges();

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task <IActionResult> Post([FromBody] TarjetaCredito tarjeta)
        {
            try
            {
                _context.Add(tarjeta);
                await _context.SaveChangesAsync();

                return(Ok(tarjeta));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 30
0
        public async Task <IActionResult> Post([FromBody] Rol rol)
        {
            try
            {
                _context.Add(rol);
                await _context.SaveChangesAsync();

                return(Ok(rol));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }