public Program createProgram(AddProgram newItem)
        {
            Program program = Mapper.Map <Program>(newItem);

            ds.Program.Add(program);
            ds.SaveChanges();
            return(program);
        }
Пример #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"));
        }
Пример #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));
        }
Пример #4
0
 public ActionResult Create(AddProgram newItem)
 {
     if (ModelState.IsValid)
     {
         m.createProgram(newItem);
         return(RedirectToAction("index"));
     }
     else
     {
         return(View(newItem));
     }
 }
 public IActionResult Create(AddProgram model)
 {
     if (ModelState.IsValid)
     {
         var program = new Programs()
         {
             ProgramName = model.ProgramName
         };
         var programId = programRepository.CreateProgram(program);
         if (programId > 0)
         {
             return RedirectToAction("Index", "Program");
         }
         ModelState.AddModelError("", "System error, please try again later!");
     }
     var programView = new AddProgram();
     return View(programView);
 }
Пример #6
0
    public static void Main(String[] args)
    {
        AddProgram add = new AddProgram();

        int result = 0;

        result = add[2, 2];

        /* === 5번 === */
        Console.WriteLine("======= 덧셈 함수(인덱서 사용) =======");
        Console.WriteLine("덧셈 결과 = " + result.ToString());
        Console.WriteLine();


        Console.WriteLine("======= 배열 요소 설정 및 출력(인덱서 사용) =======");
        for (int i = 0; i < AddProgram.SIZE; i++)
        {
            add[i] = add[(i + 1), 5]; /* === 6번 === */
            Console.WriteLine(i + 1 + "번째 데이터 = " + add[i]);
        }
    }