Ejemplo n.º 1
0
        public ActionResult DeleteMovement(int id)
        {
            JenisProgram prog = _context.JenisPrograms.FirstOrDefault(z => z.Id == id);

            _context.JenisPrograms.Remove(prog);
            _context.SaveChanges();
            return(RedirectToAction("Index", "Movement"));
        }
Ejemplo n.º 2
0
        public ActionResult AddMovement(AddProgram model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    JenisProgram prog = new JenisProgram();
                    prog.NamaProgram  = model.NamaProgram;
                    prog.Deskripsi    = model.Deskripsi;
                    prog.JenisKelamin = model.JenisKelamin;
                    prog.JenisAlat    = model.JenisAlat;
                    prog.Tingkatan    = model.Tingkatan;
                    prog.Punggung     = model.Punggung;
                    prog.Perut        = model.Perut;
                    prog.LenganTricep = model.LenganTricep;
                    prog.LenganBicep  = model.LenganBicep;
                    prog.Kaki         = model.Kaki;
                    prog.Dada         = model.Dada;
                    prog.Bahu         = model.Bahu;
                    prog.Bokong       = model.Bokong;


                    if (model.FotoGerakan != null)
                    {
                        if (model.FotoGerakan.ContentLength > 0)
                        {
                            var fileName   = Path.GetFileName(model.FotoGerakan.FileName);
                            var guid       = Guid.NewGuid().ToString();
                            var folderPath = Server.MapPath("~/uploads/" + model.NamaProgram);
                            if (!Directory.Exists(folderPath))
                            {
                                Directory.CreateDirectory(folderPath);
                            }
                            var path = Path.Combine(folderPath, fileName);
                            model.FotoGerakan.SaveAs(path);
                            string   fl        = path.Substring(path.LastIndexOf("\\"));
                            string[] split     = fl.Split('\\');
                            string   newpath   = split[1];
                            string   imagepath = "/uploads/" + model.NamaProgram + "/" + newpath;
                            prog.FotoGerakan = imagepath;
                        }
                    }
                    _context.JenisPrograms.Add(prog);
                    _context.SaveChanges();
                    TempData["Success"] = "Shop Added Successfully!";
                }
                catch (Exception e)
                {
                    TempData["Error"] = e.Message;
                }
            }



            return(RedirectToAction("Index", "Movement"));
        }
Ejemplo n.º 3
0
        public ActionResult EditMovement(int?id)
        {
            JenisProgram prog         = _context.JenisPrograms.FirstOrDefault(z => z.Id == id);
            AddProgram   editMovement = new AddProgram();

            editMovement.NamaProgram  = prog.NamaProgram;
            editMovement.Deskripsi    = prog.Deskripsi;
            editMovement.JenisKelamin = prog.JenisKelamin;
            editMovement.JenisAlat    = prog.JenisAlat;
            editMovement.Tingkatan    = prog.Tingkatan;
            return(PartialView("_editMovement", editMovement));
        }