// PUT api/Genres/5 public HttpResponseMessage PutGENRE(int id, GENRE genre) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } if (id != genre.ID_GENRE) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } db.Entry(genre).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public Human(string name, int age, GENRE genre) { Name = name; Age = age; Genre = genre; ID = Convert.ToInt16(DateTime.Now.ToString("yyyyMMddmmhhss")); }
public static bool UpdateGenre(int id, GENRE genre) { bool successfullyUpdatedMember = false; using (MovieDatabase context = new MovieDatabase()) { var genreToUpdate = context.GENREs.SingleOrDefault(row => row.id == id); try { context.Database.Connection.Open(); context.GENREs.Attach(genreToUpdate); genreToUpdate = genre; context.SaveChanges(); successfullyUpdatedMember = true; } catch (Exception ex) { } finally { context.Database.Connection.Close(); } } return(successfullyUpdatedMember); }
// ~~ public TRANSLATION MakeTranslation( string text, GENRE genre = GENRE.Neutral ) { return(new TRANSLATION(text, genre)); }
public GameData(string gameName, uint year, GENRE _genre, string _publisher, float USSales, float EUSales, float JPSales, float otherSales, float globalSales, float _criticScore, uint _criticCount, float _userScore, uint _userCount, string _developer, RATING _gameRating) { name = gameName; releaseYear = year; genre = _genre; salesUS = USSales; salesEU = EUSales; salesJP = JPSales; salesOther = otherSales; salesGlobal = globalSales; criticScore = _criticScore; criticCount = _criticCount; userScore = _userScore; userCount = _userCount; developer = _developer; publisher = _publisher; gameRating = _gameRating; }
public void DeleteGenre(int genID) { GENRE gen = dataAccess.GENREs.ToList().Single(genre => genre.GENREID == genID); dataAccess.GENREs.DeleteOnSubmit(gen); dataAccess.SaveChanges(); }
public static GameData GenerateGame(string _name, string _year, string _genre, string _publisher, string _usSales, string _euSales, string _jpSales, string _otherSales, string _globalSales, string _criticScore, string _criticCount, string _userScore, string _userCount, string _developer, string _rating) { uint year = _year != "N/A" ? Convert.ToUInt32(_year) : 0; GENRE genre = ConvertStrToGenre(_genre); float usSales = Convert.ToSingle(_usSales); float euSales = Convert.ToSingle(_euSales); float jpSales = Convert.ToSingle(_jpSales); float otherSales = Convert.ToSingle(_otherSales); float globalSales = Convert.ToSingle(_globalSales); float criticScore = (_criticScore != "" && _criticScore != "tbd") ? Convert.ToSingle(_criticScore) : -1; uint criticCount = (_criticCount != "" && _criticCount != "tbd") ? Convert.ToUInt32(_criticCount) : 0; float userScore = (_userScore != "" && _userScore != "tbd") ? Convert.ToSingle(_userScore) : -1; uint userCount = (_userCount != "" && _userCount != "tbd") ? Convert.ToUInt32(_userCount) : 0; RATING rating = ConvertStrToRating(_rating); return(new GameData(_name, year, genre, _publisher, usSales, euSales, jpSales, otherSales, globalSales, criticScore, criticCount, userScore, userCount, _developer, rating)); }
// ~~ public TRANSLATION MakeTranslation( int integer_quantity, GENRE genre = GENRE.Neutral ) { return(new TRANSLATION(integer_quantity, genre)); }
public ActionResult DeleteConfirmed(int id) { GENRE gENRE = db.GENRE.Find(id); db.GENRE.Remove(gENRE); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult ThemChuDe(string TenChuDe) { GENRE cd = new GENRE(); cd.NAME = TenChuDe; db.GENRE.Add(cd); db.SaveChanges(); return(RedirectToAction("ThemSach")); }
public ActionResult Edit([Bind(Include = "ID,NAME")] GENRE gENRE) { if (ModelState.IsValid) { db.Entry(gENRE).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gENRE)); }
public ActionResult Create([Bind(Include = "IdGenre,NomGenre,Image,Taille,Prix,Ref,Description,Couleur,NbrGenre,Etat,IdProd,IdPanier,Nouveau,Reduction,Prix1,Pour,Date,IdUser,IdCat,IdUser1")] GENRE gENRE) { if (ModelState.IsValid) { db.GENRE.Add(gENRE); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gENRE)); }
// GET api/Genres/5 public GENRE GetGENRE(int id) { GENRE genre = db.GENREs.Find(id); if (genre == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(genre); }
public ActionResult Create([Bind(Include = "ID,NAME")] GENRE gENRE) { if (ModelState.IsValid) { db.GENRE.Add(gENRE); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gENRE)); }
// -- CONSTRUCTORS public TRANSLATION( TRANSLATION translation ) { Text = translation.Text; Quantity = translation.Quantity; HasIntegerQuantity = translation.HasIntegerQuantity; HasRealQuantity = translation.HasRealQuantity; IntegerQuantity = translation.IntegerQuantity; RealQuantity = translation.RealQuantity; Genre = translation.Genre; }
// ~~ public TRANSLATION( string text, GENRE genre = GENRE.Neutral ) { Text = text; Quantity = ""; HasIntegerQuantity = false; HasRealQuantity = false; IntegerQuantity = 0; RealQuantity = 0.0; Genre = genre; }
// ~~ public TRANSLATION( int integer_quantity, GENRE genre = GENRE.Neutral ) { Text = ""; Quantity = integer_quantity.ToString(); HasIntegerQuantity = true; HasRealQuantity = false; IntegerQuantity = integer_quantity; RealQuantity = ( double )integer_quantity; Genre = genre; }
// GET: CRUD/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GENRE gENRE = db.GENRE.Find(id); if (gENRE == null) { return(RedirectToAction("HttpNotFoun", "ACCUEIL")); } return(View(gENRE)); }
public void UpdateGenre(GENRE genre) { foreach (GENRE gen in dataAccess.GENREs.ToList()) { if (gen.GENREID == genre.GENREID) { gen.NAME = genre.NAME; gen.DESCRIPTION = genre.DESCRIPTION; gen.REFERENCE_KEY = genre.REFERENCE_KEY; } } dataAccess.SaveChanges(); }
// GET: GENREs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GENRE gENRE = db.GENRE.Find(id); if (gENRE == null) { return(HttpNotFound()); } return(View(gENRE)); }
public ActionResult Remise(int?id, double?Reduction, string Tout = "") { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } List <GENRE> ListGenre = new List <GENRE>(); ListGenre = db.GENRE.Where(x => x.IdUser == ANDRANA.IDUSER).ToList(); GENRE gENRE = db.GENRE.Find(id); gENRE.Prix1 = (gENRE.Prix - (gENRE.Prix * Reduction) / 100); ViewBag.E = Convert.ToInt32(gENRE.Prix1); using (SqlConnection SqlCon = new SqlConnection(connectionString)) { SqlCon.Open(); if (Tout == "Un") { string query = "UPDATE GENRE SET Prix1='" + Convert.ToInt32(gENRE.Prix1) + "',Reduction='" + Reduction + "' where IdGenre='" + id + "' "; SqlCommand SqlCom = new SqlCommand(query, SqlCon); SqlCom.ExecuteNonQuery(); ViewBag.Message = "Lavoaloany"; } else if (Tout == "Tout") { foreach (var item in ListGenre) { item.Prix1 = (item.Prix - (item.Prix * Reduction) / 100); string query = "UPDATE GENRE SET Prix1='" + Convert.ToInt32(item.Prix1) + "',Reduction='" + Reduction + "' where IdGenre='" + item.IdGenre + "' "; SqlCommand SqlCom = new SqlCommand(query, SqlCon); SqlCom.ExecuteNonQuery(); ViewBag.Message = "La réduction de prix des articles sont effectuées avec succès"; } } } if (gENRE == null) { return(RedirectToAction("HttpNotFoun", "ACCUEIL")); } return(RedirectToAction("Index", new { @lm = "vvvv" })); } catch { return(RedirectToAction("HttpNotFoun", "ACCUEIL")); } }
// POST api/Genres public HttpResponseMessage PostGENRE(GENRE genre) { if (ModelState.IsValid) { db.GENREs.Add(genre); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, genre); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = genre.ID_GENRE })); return(response); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } }
public ActionResult Edit([Bind(Include = "IdGenre,NomGenre,Image,Taille,Prix,Ref,Description,Couleur,NbrGenre,Etat,IdProd,IdPanier,Nouveau,Reduction,Prix1,Pour,Date,IdUser,IdCat,IdUser1")] GENRE gENRE) { try { if (ModelState.IsValid) { db.Entry(gENRE).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gENRE)); } catch { return(RedirectToAction("HttpNotFoun", "ACCUEIL")); } }
// ~~ public string GetGenreText( GENRE genre ) { if (genre == GENRE.Male) { return("male"); } else if (genre == GENRE.Female) { return("female"); } else { return("neutral"); } }
// ~~ public TRANSLATION( string text, string quantity, GENRE genre = GENRE.Neutral ) { Text = text; Quantity = ""; HasIntegerQuantity = false; HasRealQuantity = false; IntegerQuantity = 0; RealQuantity = 0.0; Genre = genre; if (quantity.Length > 0) { SetQuantity(quantity); } }
public ActionResult Create(GENRE genre) { try { if (ModelState.IsValid) { GenreModel.AddGenre(genre); ViewBag.Message = SuccessMessage.GENRE_ADDED_MESSAGE; } else { ViewBag.ErrorMessage = ErrorMessage.REQUIRED_ASTERIC_FIELDS; } return(View()); } catch { ViewBag.ErrorMessage = ErrorMessage.INTERNAL_ERROR; return(View()); } }
// DELETE api/Genres/5 public HttpResponseMessage DeleteGENRE(int id) { GENRE genre = db.GENREs.Find(id); if (genre == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } db.GENREs.Remove(genre); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK, genre)); }
public static bool AddGenre(GENRE genre) { bool successfullyAddedGenre = false; using (MovieDatabase context = new MovieDatabase()) { try { context.Database.Connection.Open(); context.GENREs.Add(genre); context.SaveChanges(); successfullyAddedGenre = true; } catch (Exception ex) { } finally { context.Database.Connection.Close(); } } return(successfullyAddedGenre); }
// GET: CRUD/Delete/5 public ActionResult Delete(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GENRE gENRE = db.GENRE.Find(id); db.GENRE.Remove(gENRE); db.SaveChanges(); if (gENRE == null) { return(RedirectToAction("HttpNotFoun", "ACCUEIL")); } return(RedirectToAction("Index", new { @lm = "vb" })); } catch { return(RedirectToAction("HttpNotFoun", "ACCUEIL")); } }
//public ActionResult Panier() //{ // DataTable dt = new DataTable(); // using (SqlConnection SqlCon = new SqlConnection(connectionString)) // { // SqlCon.Open(); // string query = "SELECT * FROM PANIER"; // SqlDataAdapter SqlDa = new SqlDataAdapter(query, SqlCon); // SqlDa.Fill(dt); // } // return RedirectToAction("Terminer", new { III = IDPANIER }); //} public ActionResult Panier(int IdGenre, int?NbrGenre) { try { int nbrLigne = 0; DataTable dt = new DataTable(); using (SqlConnection SqlCon = new SqlConnection(connectionString)) { SqlCon.Open(); string query = "SELECT * FROM PANIER"; SqlDataAdapter SqlDa = new SqlDataAdapter(query, SqlCon); SqlDa.Fill(dt); } nbrLigne = Convert.ToInt32(dt.Rows.Count.ToString()); int val = 1; if (dt.Rows.Count == 0) { // ViewBag.Gen = IdGenre; using (SqlConnection SqlCon = new SqlConnection(connectionString)) { SqlCon.Open(); MyStoreEntities4 b = new MyStoreEntities4(); GENRE g = new GENRE(); //g = b.GENRE.Where(x => x.IdGenre == IdGenre).First(); //int NbrGenre1 = (Convert.ToInt32(g.NbrGenre) - Convert.ToInt32(NbrGenre)); //string query = "UPDATE GENRE SET IdPanier='" + val + "',NbrGenre='" + NbrGenre1 + "',NbrAch='" + NbrGenre + "' where IdGenre='" + IdGenre + "' "; g = b.GENRE.Where(x => x.IdGenre == IdGenre).First(); int NbrGenre1 = (Convert.ToInt32(g.NbrGenre) - Convert.ToInt32(NbrGenre)); string query = "UPDATE GENRE SET IdPanier='" + val + "' where IdGenre='" + IdGenre + "' "; SqlCommand SqlCom = new SqlCommand(query, SqlCon); IDPANIER = val; ViewBag.MonParam1 = IDPANIER; ANDRANA.IDPANIER = IDPANIER; SqlCom.ExecuteNonQuery(); } return(RedirectToAction("Terminer", new { III = IDPANIER, N = NbrGenre })); } else { MyStoreEntities4 b = new MyStoreEntities4(); PANIER p1 = new PANIER(); p1 = b.PANIER.ToList().Last(); val = p1.IdPanier + 1; using (SqlConnection SqlCon = new SqlConnection(connectionString)) { SqlCon.Open(); GENRE g = new GENRE(); g = b.GENRE.Where(x => x.IdGenre == IdGenre).First(); //int NbrGenre1=(Convert.ToInt32(g.NbrGenre) - Convert.ToInt32(NbrGenre)); // string query = "UPDATE GENRE SET IdPanier='"+val+"',NbrGenre='"+ NbrGenre1 + "',NbrAch='"+NbrGenre+"' where IdGenre='" + IdGenre + "' "; int NbrGenre1 = (Convert.ToInt32(g.NbrGenre) - Convert.ToInt32(NbrGenre)); string query = "UPDATE GENRE SET IdPanier='" + val + "' where IdGenre='" + IdGenre + "' "; SqlCommand SqlCom = new SqlCommand(query, SqlCon); IDPANIER = val; ViewBag.MonParam1 = IDPANIER; ANDRANA.IDPANIER = IDPANIER; SqlCom.ExecuteNonQuery(); } ViewBag.K = IdGenre; ViewBag.S = NbrGenre; //return View(); return(RedirectToAction("Terminer", new { III = IDPANIER, N = NbrGenre })); } } catch { return(RedirectToAction("HttpNotFoun", "ACCUEIL")); } }