Пример #1
0
        public static bool Update(Rezervimet rezervimet, int id)
        {
            var conn = DBHelper.GetConnection();

            try
            {
                var cmd = new SqlCommand("dbo.usp_Rezervimet_Edit", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@RezervimetID", id);
                cmd.Parameters.AddWithValue("@GrupiID", rezervimet.GrupiID);
                cmd.Parameters.AddWithValue("@ProfesoriID", rezervimet.ProfesoriID);
                cmd.Parameters.AddWithValue("@SallaID", rezervimet.SallaID);
                cmd.Parameters.AddWithValue("@LendaId", rezervimet.LendaID);
                cmd.Parameters.AddWithValue("@Fillimi", rezervimet.Fillimi);
                cmd.Parameters.AddWithValue("@Mbarimi", rezervimet.Mbarimi);
                cmd.Parameters.AddWithValue("@statusi", rezervimet.statusi);
                cmd.Parameters.AddWithValue("@LastUpdate", rezervimet.LastUpdate);



                conn.Open();
                cmd.ExecuteNonQuery();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                conn.Close();
            }
        }
Пример #2
0
        public static List <Rezervimet> List()
        {
            var list = new List <Rezervimet>();
            var conn = DBHelper.GetConnection();
            var cmd  = new SqlCommand("dbo.usp_Rezervimet_List", conn);

            cmd.CommandType = CommandType.StoredProcedure;


            try
            {
                conn.Open();

                var rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    var rezervimet = new Rezervimet();
                    // rezervimet.GrupiID = int.Parse(rdr["RezervimetID"].ToString());
                    //  grupi.LastUpdate = string.IsNullOrEmpty(rdr["LastUpdate"].ToString()) == true ? DateTime.Now : DateTime.Parse(rdr["LastUpdated"].ToString());

                    list.Add(rezervimet);
                }
                return(list);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                conn.Close();
            }
        }
Пример #3
0
 public ActionResult Create(Rezervimet rezervimet)
 {
     rezervimet.CreatedOn = DateTime.Now;
     if (RezervimetDAL.Insert(rezervimet))
     {
         return(Redirect("Index"));
     }
     return(Redirect("Index"));
 }
Пример #4
0
 public ActionResult Delete(int id, Rezervimet rezervimet)
 {
     try
     {
         // TODO: Add delete logic here
         ProfesoratDAL.Delete(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Пример #5
0
 public ActionResult Edit(int id, Rezervimet rezervimet)
 {
     try
     {
         if (ModelState.IsValid)
         {
             RezervimetDAL.Update(rezervimet, id);
             return(RedirectToAction("Index"));
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Пример #6
0
        public static Rezervimet Read(int id)
        {
            var rezervimet = new Rezervimet();
            var conn       = DBHelper.GetConnection();
            var cmd        = new SqlCommand("dbo.usp_Rezervimet_Read", conn);

            cmd.CommandType = CommandType.StoredProcedure;

            try
            {
                if (id != 0)
                {
                    cmd.Parameters.AddWithValue("@RezervimetID", id);

                    conn.Open();
                    var rdr = cmd.ExecuteReader();

                    if (rdr.Read())
                    {
                        rezervimet.RezervimeID = int.Parse(rdr["rezervimetID"].ToString());
                    }
                    return(rezervimet);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                return(null);
            }
            finally
            {
                conn.Close();
            }
        }
Пример #7
0
        // GET: Rezervimet/Details/5
        public ActionResult Details(int id)
        {
            Rezervimet rezervimet = RezervimetDAL.Read(id);

            return(View("Details", rezervimet));
        }