Exemplo n.º 1
0
        public static int InsertType(TypeProgram t)
        {
            NGOEntities e         = new NGOEntities();
            var         checkName = e.TypePrograms.SingleOrDefault(s => s.TypeName.ToLower() == t.TypeName.ToLower());

            if (checkName != null)
            {
                return(-1);
            }
            e.TypePrograms.Add(t);
            if (e.SaveChanges() > 0)
            {
                return(t.ID);
            }
            return(0);
        }
Exemplo n.º 2
0
        public static int UpdateType(TypeProgram t)
        {
            NGOEntities e         = new NGOEntities();
            var         checkName = e.TypePrograms.SingleOrDefault(s => s.TypeName.ToLower() == t.TypeName.ToLower() && s.ID != t.ID);

            if (checkName != null)
            {
                return(-1);
            }
            var item = e.TypePrograms.Find(t.ID);

            item.TypeName = t.TypeName;
            if (e.SaveChanges() > 0)
            {
                return(t.ID);
            }
            return(0);
        }
Exemplo n.º 3
0
        public ActionResult CreateType(TypeProgram tp)
        {
            int stt = Repositories.InsertType(tp);

            if (stt == -1)
            {
                TempData["error"] = "Duplicate name!";
            }
            else if (stt == 0)
            {
                TempData["error"] = "Create new type failed!";
            }
            else
            {
                TempData["success"] = "Create new type successfully!";
            }
            return(RedirectToAction("TypeProgram"));
        }
Exemplo n.º 4
0
        public ActionResult UpdateType(TypeProgram tp)
        {
            int stt = Repositories.UpdateType(tp);

            if (stt == -1)
            {
                TempData["error"] = "Duplicate name!";
                return(RedirectToAction("EditType", new { id = tp.ID }));
            }
            else if (stt == 0)
            {
                TempData["error"] = "Update type failed!";
            }
            else
            {
                TempData["success"] = "Update type successfully!";
            }
            return(RedirectToAction("TypeProgram"));
        }
Exemplo n.º 5
0
        public ActionResult EditType(int id)
        {
            TypeProgram type = Repositories.GetTypeByID(id);

            return(View(type));
        }
Exemplo n.º 6
0
 public static int UpdateType(TypeProgram t)
 {
     return(TypeProgramDAO.UpdateType(t));
 }
Exemplo n.º 7
0
 public static int InsertType(TypeProgram t)
 {
     return(TypeProgramDAO.InsertType(t));
 }