public async Task <IActionResult> PutBorrowed(int id, Borrowed borrowed) { if (id != borrowed.BorrowedId) { return(BadRequest()); } _context.Entry(borrowed).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BorrowedExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Borrowed> > PostBorrowed(Borrowed borrowed) { _context.Borrowed.Add(borrowed); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBorrowed", new { id = borrowed.BorrowedId }, borrowed)); }
public ActionResult CreateBill(int memberId, DateTime returnDate) { int staffId; int.TryParse(Request.Cookies["ID"].Value, out staffId); Borrowed borrowed = new Borrowed { MemberID = memberId, StaffID = staffId, BorrowedTime = DateTime.Now, ReturnDeadline = returnDate, TotalPrice = 0, Return = false }; int numberOfDays = (int)(returnDate - DateTime.Now).TotalDays; double totalPrice = 0; _db.Borroweds.Add(borrowed); List <int> listBookIDs = (List <int>)Session["bill"]; for (int i = 0; i < listBookIDs.Count; i++) { BorrowedDetail borrowedDetail = new BorrowedDetail { BookID = listBookIDs[i], BorrowID = borrowed.ID }; int bookId = listBookIDs[i]; var price = (from b in _db.Books where b.ID == bookId select b.Price).SingleOrDefault(); totalPrice += (price * numberOfDays); _db.BorrowedDetails.Add(borrowedDetail); } borrowed.TotalPrice = (float)totalPrice; _db.SaveChanges(); return(RedirectToAction("Index", new { key = borrowed.ID })); }
public ActionResult DeleteConfirmed(int id) { Borrowed borrowed = db.Borroweds.Find(id); db.Borroweds.Remove(borrowed); db.SaveChanges(); return(RedirectToAction("Index", "Books")); }
/// <summary> /// Deletes an borrowed /// </summary> /// <param name="borrowed">Borrowed</param> public virtual void DeleteBorrowed(Borrowed borrowed) { if (borrowed == null) { throw (new ArgumentNullException("parameter missing")); } _borrowedRepository.Delete(borrowed); }
public void DeliverBookToLib(Guid code, DateTime deliveryTime) { var data = context.borroweds(); int tmp = data.FindIndex(a => a.BookCode == code); Borrowed borrowed = GetBorrowedByBookCode(code); borrowed.DeliveryTime = deliveryTime; data[tmp] = borrowed; context.SaveChangesForBorroweds(data); }
public ActionResult BorrowIndex(int bookid, int userid, Borrowed borrowed) { borrowed.BookID = bookid; borrowed.UserID = userid; db.Borroweds.Add(borrowed); db.SaveChanges(); olvm.borrowedsList = db.Borroweds.Where(x => x.UserID == userid).ToList(); return(View(olvm)); }
public void AddToBorrowed(Borrowed borrowed) { var data = context.borroweds(); if (data == null) { data = new List <Borrowed>(); } data.Add(borrowed); context.SaveChangesForBorroweds(data); }
public Borrowed GetBorrowedByBookCode(Guid code) { Borrowed borrowed; try { borrowed = GetAllBorroweds().Single(a => a.BookCode == code && a.DeliveryTime == DateTime.MinValue); } catch (Exception) { return(null); } return(borrowed); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Borrowed borrowed = db.Borroweds.Find(id); if (borrowed == null) { return(HttpNotFound()); } return(View()); }
public BorrowedRepository() { borrowed = new Borrowed(); context = new Context(); }
public void UseBorrowed(Borrowed <MockDisposable> borrowed) { }
/// <summary> /// Drops all references to objects. /// </summary> /// <remarks>Useful call before returning to a pool.</remarks> public void ClearReferences() { this.BorrowedGuild = null; }
/// <summary> /// Set this result to the <see cref="ResultType.Success"/> type. /// </summary> /// <param name="borrowedGuild">The borrowed guild to return.</param> public void ToSuccess(Borrowed <Guild> borrowedGuild) { this.Result = ResultType.Success; this.BorrowedGuild = borrowedGuild; }
public ActionResult Create(Loan loan, HttpPostedFileBase fileAgreement, HttpPostedFileBase fileIrrevocable, HttpPostedFileBase fileGuarantors) { if (ModelState.IsValid) { #region Validate File Type string fileAgreementName, fileIrrevocableName, fileGuarantorsName, extension; if (fileAgreement != null && fileAgreement.ContentLength > 0) { extension = Path.GetExtension(fileAgreement.FileName); if (extension != ".jpg" && extension != ".jpeg" && extension != ".png") { ModelState.AddModelError("Invalid Image", "Please upload .jpg or .png image."); return(View(loan)); } fileAgreementName = Guid.NewGuid() + extension; loan.ImgAgreementUrl = ConfigurationManager.AppSettings["Azure:StorageUrl"] + BlobContainer.loan.ToString() + "/" + fileAgreementName; } else { ModelState.AddModelError("Invalid Image", "Please upload image for signed agreement form."); return(View(loan)); } if (fileIrrevocable != null && fileIrrevocable.ContentLength > 0) { extension = Path.GetExtension(fileIrrevocable.FileName); if (extension != ".jpg" && extension != ".jpeg" && extension != ".png") { ModelState.AddModelError("Invalid Image", "Please upload .jpg or .png image."); return(View(loan)); } fileIrrevocableName = Guid.NewGuid() + extension; loan.ImgIrrevocableUrl = ConfigurationManager.AppSettings["Azure:StorageUrl"] + BlobContainer.loan.ToString() + "/" + fileIrrevocableName; } else { ModelState.AddModelError("Invalid Image", "Please upload image for signed irrevocable authority form."); return(View(loan)); } if (fileGuarantors != null && fileGuarantors.ContentLength > 0) { extension = Path.GetExtension(fileGuarantors.FileName); if (extension != ".jpg" && extension != ".jpeg" && extension != ".png") { ModelState.AddModelError("Invalid Image", "Please upload .jpg or .png image."); return(View(loan)); } fileGuarantorsName = Guid.NewGuid() + extension; loan.ImgGuarantorsUrl = ConfigurationManager.AppSettings["Azure:StorageUrl"] + BlobContainer.loan.ToString() + "/" + fileGuarantorsName; } else { ModelState.AddModelError("Invalid Image", "Please upload image for signed irrevocable authority form."); return(View(loan)); } #endregion if (!_context.Customers.Any(x => x.AccountNo == loan.AccountNo)) { ModelState.AddModelError("Account Not Exists", "Account does not exists."); return(View(loan)); } var deposit = _context.CustomerSavings.Where(x => x.AccountNo == loan.AccountNo).Sum(x => x.Credit - x.Debit); var percent = loan.amount * Convert.ToDecimal(0.10); if (deposit <= percent) { ModelState.AddModelError("No 10% Deposit", "This customer has no 10% deposit in his/her account."); return(View(loan)); } loan.LoanStatus = "active"; //set loan status to active loan.Customername = (from s in _context.Customers where s.AccountNo == loan.AccountNo select s.Name).FirstOrDefault(); if (loan.Customername == null || loan.Customername == "") { //return customer not registered errorr:09256A return(Redirect("~/Error/ErrorCode?ErrorCode=09256A")); } //if we get here customer has been enrolled loan.createdby = User.Identity.Name.ToString(); //loan.DateCreated = DateTime.Now.ToShortDateString(); loan.DateCreated = DateTime.Now; //DateTime completionDate = DateTime.Parse(loan.DateOfCommencement).AddMonths(Int32.Parse(loan.Duration)); DateTime completionDate = loan.DateOfCommencement.AddMonths(Int32.Parse(loan.Duration)); //loan.DateOfTermination = completionDate.ToShortDateString(); loan.DateOfTermination = completionDate; //save amount borrowed var amountBorred = new Borrowed { DateCreated = DateTime.Now.ToShortDateString(), accountNo = loan.AccountNo, amountborrowed = loan.amount }; //create a loan transaction record var loanTransaction = new LoanTransaction { DateCreated = DateTime.Now.ToShortDateString(), AccountNo = loan.AccountNo, amount = loan.amount, refund = decimal.Parse("0"),//credit createdby = User.Identity.Name.ToString() }; //customer must pay 10% of loan upfront. create loan interest record. var loanInterest = new LoanInterest { accountNo = loan.AccountNo, intrestAmount = Decimal.Parse("0.1") * loan.amount, }; _context.LoanInterests.Add(loanInterest); _context.Borrows.Add(amountBorred); _context.Loans.Add(loan); _context.LoanTransactions.Add(loanTransaction); _context.SaveChanges(); #region Save Images if (fileAgreement != null && fileAgreement.ContentLength > 0) { FileHelper.UploadImage(fileAgreement.InputStream, fileAgreementName, BlobContainer.loan); } if (fileIrrevocable != null && fileIrrevocable.ContentLength > 0) { FileHelper.UploadImage(fileIrrevocable.InputStream, fileIrrevocableName, BlobContainer.loan); } if (fileGuarantors != null && fileGuarantors.ContentLength > 0) { FileHelper.UploadImage(fileGuarantors.InputStream, fileGuarantorsName, BlobContainer.loan); } #endregion return(RedirectToAction("Index")); } return(View(loan)); }
public Given_an_instance_of_a_BorrowedDisposable() { _borrowedDisposable = Disposable.AsBorrowed(); }
public Given_an_instance_of_a_BorrowedDisposable_with_strict_mode_set() { _borrowedDisposable = Disposable.AsBorrowed(isStrict: true); }