public ActionResult DeleteConfirmed(int id) { DVDDetails dVDDetails = db.DVDDetails.Find(id); db.DVDDetails.Remove(dVDDetails); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "DVDDetailsId,StockedDate,Name,Genre,AgeRestricted,NumberOfCopies,ReleaseDate,isDeleted,Length,CoverImagePath")] DVDDetails dVDDetails) { if (ModelState.IsValid) { db.Entry(dVDDetails).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dVDDetails)); }
public ActionResult Edit([Bind(Include = "Id,Name,ReleaseDate,Length,CoverImagePath")] DVDDetails dVDDetails) { if (ModelState.IsValid) { db.Entry(dVDDetails).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dVDDetails)); }
public ActionResult Create([Bind(Include = "Id,Name,ReleaseDate,Length,CoverImagePath")] DVDDetails dVDDetails) { if (ModelState.IsValid) { db.DVDDetails.Add(dVDDetails); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dVDDetails)); }
// GET: DVDDetails/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DVDDetails dVDDetails = db.DVDDetails.Find(id); if (dVDDetails == null) { return(HttpNotFound()); } return(View(dVDDetails)); }
public ActionResult Create([Bind(Include = "DVDDetailsId,StockedDate,Name,Genre,AgeRestricted,NumberOfCopies,ReleaseDate,isDeleted,Length,CoverImage,CoverImagePath")] DVDDetails dVDDetails) { if (ModelState.IsValid) { string fileName = Path.GetFileNameWithoutExtension(dVDDetails.CoverImage.FileName); string extension = Path.GetExtension(dVDDetails.CoverImage.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; dVDDetails.CoverImagePath = "~/Image/" + fileName; fileName = Path.Combine(Server.MapPath("~/Image/"), fileName); dVDDetails.CoverImage.SaveAs(fileName); db.DVDDetails.Add(dVDDetails); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dVDDetails)); }
public ActionResult DVDNotBorrowedInMonth() { var allDVDList = db.DVDDetails.Select(x => x.DVDDetailsId); var allLoanedList = db.Loans.Include("DVDDetails").Select(x => x.DVDDetailsId); List <int> neverLoanedDVDList = new List <int>(); List <int> currentlyNotLoanedList = new List <int>(); List <int> allLoanedDVDIDList = new List <int>(); List <int> loanNotNulledList = new List <int>(); List <int> falseDataList = new List <int>(); List <int> notcontainslist = new List <int>(); List <int> datelimitedList = new List <int>(); //final sending list List <Models.DVDDetails> finalSendingList = new List <Models.DVDDetails>(); foreach (var dvd in allDVDList) { if (!allLoanedList.Contains(dvd)) { neverLoanedDVDList.Add(dvd); } else { } } foreach (var x in neverLoanedDVDList) { Debug.WriteLine("never loaned dvd: " + x); } var loanedTableOldDVD = db.Loans.Include("DVDDetails"); foreach (var x in allLoanedList) { allLoanedDVDIDList.Add(x); } var distinctAllLoanTableDVDID = allLoanedDVDIDList.Distinct(); bool flag = true; foreach (var dis in distinctAllLoanTableDVDID) { foreach (var loanT in loanedTableOldDVD) { if (loanT.DVDDetailsId == dis) { if (loanT.ActualReturnedDate == null) { Debug.WriteLine("im in false flag"); falseDataList.Add(dis); flag = false; } else { } } } if (flag == true) { loanNotNulledList.Add(dis); } flag = true; } foreach (var v in loanNotNulledList) { if (!falseDataList.Contains(v)) { notcontainslist.Add(v); } } //var days = (Convert.ToDateTime(DateTime.Now) - Convert.ToDateTime(each.IssueDate)).TotalDays; //if (days >= 31) { // currentlyNotLoanedList.Add(each.DVDDetailsId); //} //================================================================ bool flagM = true; foreach (var dis in notcontainslist) { foreach (var loanT in loanedTableOldDVD) { if (loanT.DVDDetailsId == dis) { var days = (Convert.ToDateTime(DateTime.Now) - Convert.ToDateTime(loanT.IssueDate)).TotalDays; if (days < 30) { flagM = false; } else { } } } if (flagM == true) { datelimitedList.Add(dis); } flagM = true; } //================================================================= var allGoodList = neverLoanedDVDList.Concat(datelimitedList).Distinct().ToList(); Models.DVDDetails dvdD = new Models.DVDDetails(); IList <DVDDetails> sendData = new List <DVDDetails>(); foreach (var z in allGoodList) { finalSendingList = db.DVDDetails.Where(x => x.DVDDetailsId == z).ToList(); foreach (var data in finalSendingList) { DVDDetails dvdDet = new DVDDetails(); dvdDet.DVDDetailsId = data.DVDDetailsId; dvdDet.Name = data.Name; dvdDet.Genre = data.Genre; dvdDet.ReleaseDate = data.ReleaseDate; dvdDet.Length = data.Length; dvdDet.CoverImagePath = data.CoverImagePath; dvdDet.NumberOfCopies = data.NumberOfCopies; dvdDet.AgeRestricted = data.AgeRestricted; dvdDet.StockedDate = data.StockedDate; dvdDet.isDeleted = data.isDeleted; sendData.Add(dvdDet); } } return(View(sendData)); }