public async Task <IActionResult> PutRentDetail([FromRoute] int id, [FromBody] RentDetail rentDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != rentDetail.ID) { return(BadRequest()); } _context.Entry(rentDetail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RentDetailExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutRentDetail(int id, RentDetail rentDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != rentDetail.ID) { return(BadRequest()); } db.Entry(rentDetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RentDetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.Created)); }
private async Task EditionModeToggle() { if (_editionMode) { EditBtn.Text = "Editar"; CleanForm(); } else { _entityToEdit = await _rentDetail.Get(GetIdCurrentRow()); EditBtn.Text = "Cancelar"; commentTxt.Text = _entityToEdit.Comment; nPriceByDay.Value = (decimal)_entityToEdit.PriceByDay; nRentDays.Value = _entityToEdit.RentDays; dpRentDate.Value = _entityToEdit.RentDate; cbEmployee.SelectedValue = _entityToEdit.EmployeeId; cbCustomer.SelectedValue = _entityToEdit.CustomerId; cbVehicle.SelectedValue = _entityToEdit.VehicleId; cbStatus.SelectedItem = _entityToEdit.Status; } DeleteBtn.Enabled = !DeleteBtn.Enabled; rentDataGrid.Enabled = !rentDataGrid.Enabled; _editionMode = !_editionMode; }
public Response <RentDetail> FetchOneById(int id) { Response <RentDetail> res = new Response <RentDetail>(); try { using (var rentDetailRepo = new RentDetailRepository()) { res.Data = new List <RentDetail>(); RentDetail temp = rentDetailRepo.FetchById(id); if (temp != null) { res.Data.Add(temp); res.isSuccess = true; res.Message = "Kira detay bilgisi gösteriliyor"; } else { res.isSuccess = false; res.Message = "Kira detay bilgisi gösterilirken bir sorun ile karşılaşıldı"; } } return(res); } catch (Exception ex) { throw new Exception("An error occured in FetchOneById() function in SpiceApp.BusinessLayer.RentDetailBusiness", ex); } }
public IResult Add(RentDetail rentDetail) { if (rentDetail.ReturnDate == null) { return(new ErrorResult(Messages.RentalError)); } _rentDetailDal.Add(rentDetail); return(new SuccessResult(Messages.CarRented)); }
public IResult Update(RentDetail rentDetail) { // if (rentDetail.RentDate>DateTime.Now) // { // return new ErrorResult(Messages.RentalError); // } _rentDetailDal.Update(rentDetail); return(new SuccessResult(Messages.CarRentedUpdated)); }
public IActionResult Add(RentDetail rentDetail) { var result = _rentDetailService.Add(rentDetail); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public async Task <IActionResult> PostRentDetail([FromBody] RentDetail rentDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.RentDetails.Add(rentDetail); await _context.SaveChangesAsync(); return(CreatedAtAction("GetRentDetail", new { id = rentDetail.ID }, rentDetail)); }
public IHttpActionResult DeleteRentDetail(int id) { RentDetail rentDetail = db.RentDetails.Find(id); if (rentDetail == null) { return(NotFound()); } db.RentDetails.Remove(rentDetail); db.SaveChanges(); return(Ok(rentDetail)); }
public JsonResult AddRentDetail(RentDetail rent, int PropertyID, int TenantID) { JsonResult result = new JsonResult(); if (ModelState.IsValid) { using (db) { UserAccount usr = db.UserAccounts.Where(u => u.UserName.Equals(User.Identity.Name.ToString())).FirstOrDefault(); if (rent.MonthlyRent == null) { rent.MonthlyRent = 0; } if (rent.Electricity == null) { rent.Electricity = 0; } if (rent.WaterSupply == null) { rent.WaterSupply = 0; } if (rent.Miscellaneous == null) { rent.Miscellaneous = 0; } if (rent.AmountPayed == null) { rent.AmountPayed = 0; } UserRentDetail usrRent = new UserRentDetail { UserID = usr.UserID, PropertyID = PropertyID, TenantID = TenantID, RentID = rent.RentID }; db.RentDetails.Add(rent); db.UserRentDetails.Add(usrRent); db.SaveChanges(); result.Data = new { Success = true }; } } else { result.Data = new { Success = false, Error = "Unable to save. Please enter valid values." }; } return(result); }
public ActionResult EditRentDetail(int?RentID) { if (RentID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RentDetail rentObj = db.RentDetails.Find(RentID); if (rentObj == null) { return(HttpNotFound()); } return(PartialView(rentObj)); }
public RentDetailVM(RentDetail rent) { Fecha = rent.RentDate; Cliente = rent.Customer.Name; CedulaCliente = rent.Customer.Identification; Empleado = rent.Employee.Name; Precio = "US$ " + string.Format("{0:#.00}", rent.PriceByDay); Vehiculo = rent.Vehicle.Description; Modelo = rent.Vehicle.VehicleModel.Description; Matricula = rent.Vehicle.NoLicensePlate; NoChasis = rent.Vehicle.NoChassis; NoMotor = rent.Vehicle.NoMotor; DiasRenta = rent.RentDays; Comentario = rent.Comment; }
public JsonResult EditRentDetail(int?RentID, RentDetail rentObj) { JsonResult result = new JsonResult(); if (ModelState.IsValid) { if (rentObj.MonthlyRent == null) { rentObj.MonthlyRent = 0; } if (rentObj.Electricity == null) { rentObj.Electricity = 0; } if (rentObj.WaterSupply == null) { rentObj.WaterSupply = 0; } if (rentObj.Miscellaneous == null) { rentObj.Miscellaneous = 0; } if (rentObj.AmountPayed == null) { rentObj.AmountPayed = 0; } db.Entry(rentObj).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); result.Data = new { Success = true }; } else { result.Data = new { Success = false, Error = "Unable to save. Please enter valid values." }; } return(result); }
static void Main(string[] args) { /* * ReCapManager reCapManager = new ReCapManager(new InMemoryReCapDal()); * foreach (var car in reCapManager.GetAll()) * { * Console.WriteLine("carid: " + car.CarId + " carbrandid: " + car.BrandId + " carcolorid: " + car.ColorId + " carname: " + car.CarName + " cardailyprice: " + car.DailyPrice + " cardescription: " + car.Description); + } + + ReCapManager reCapManager1 = new ReCapManager(new InMemoryReCapDal()); + foreach (var car in reCapManager1.GetAll()) + { + Console.WriteLine(car.CarName); + } */ RentDetailManager rentDetailManager = new RentDetailManager(new EfRentDetailDal()); RentDetail rentDetail = new RentDetail { CarId = 1, CustomerId = 3, RentDate = new DateTime(2021, 03, 14), ReturnDate = new DateTime(2021, 03, 16) }; Console.WriteLine(rentDetailManager.Add(rentDetail).Message); BrandManager categoryManager = new BrandManager(new EfBrandDal()); foreach (var category in categoryManager.GetAll().Data) { Console.WriteLine(category.BrandName); } Console.WriteLine("-----------------------"); ReCapManager carManager1 = new ReCapManager(new EfCarDal()); var result1 = carManager1.GetCarDetails(); if (result1.Success) { foreach (var car in result1.Data) { Console.WriteLine(car.CarName + " " + car.BrandName + " " + car.ColorName); } } else { Console.WriteLine(result1.Message); } Console.WriteLine("-----------------------"); var result = carManager1.GetAll(); if (result.Success) { foreach (var car in result.Data) { Console.WriteLine(car.CarName); } } else { Console.WriteLine(result.Message); } Console.WriteLine("-----------------------"); foreach (var car in carManager1.GetCarsByBrandId(4).Data) { Console.WriteLine(car.CarName); } Console.WriteLine("-----------------------"); foreach (var car in carManager1.GetCarsByColorId(7).Data) { Console.WriteLine(car.CarName); } carManager1.Add(new Car { CarId = 9, BrandId = 6, ColorId = 3, CarName = "volkswagenpassat", DailyPrice = 400, CarDescription = "Ciziksiz, 2021 model,beyaz" }); Console.ReadLine(); }
// make rent lists public ArrayList makeRentList() { rentlist = new ArrayList(); totalAmount = 0; int cnt = 0; foreach (Individual product in products) { RentDetail detail = new RentDetail(); range = (RentRange)productsRange[cnt]; decimal indAmount = detail.CalLIAmountTotal(product.RentPerDay, range); detail = makeRentDetail( product.IndCanoeID, range.ReturnDate, null, 0, 1, indAmount); rentlist.Add(detail); totalAmount += indAmount; cnt++; } return rentlist; }
// set rentdetail instance private RentDetail setRentDetail(DataTable dt) { RentDetail detail = new RentDetail(); detail.RentID = (int)dt.Rows[0][0]; detail.CustomerID = (int)dt.Rows[0][1]; try { detail.RentDate = (DateTime)dt.Rows[0][2]; } catch (Exception) { } try { detail.ReturnDate = (DateTime)dt.Rows[0][3]; } catch (Exception) {} detail.TotalAmount = (decimal)dt.Rows[0][4]; detail.IndCanoeID = (int)dt.Rows[0][6]; try { detail.ReturnDueDate = (DateTime)dt.Rows[0][7]; } catch (Exception) {} try { detail.ReturnDate = (DateTime)dt.Rows[0][8]; } catch (Exception) { } detail.PenaltyAmount = (decimal)dt.Rows[0][9]; detail.Quantity = (int)dt.Rows[0][10]; detail.LIAmountTotal = (decimal)dt.Rows[0][11]; return detail; }
public RentDetail makeRentDetail(int indCanoeID, DateTime? returnDueDate, DateTime? returnDate, decimal penaltyAmount, int quantity, decimal lIAmountTotal) { Individual ind = new Individual(); ind = searchDAOIndividualById(indCanoeID); RentDetail detail = new RentDetail( indCanoeID, returnDueDate, returnDate, penaltyAmount, quantity, lIAmountTotal, ind ); return detail; }
public IActionResult GetByRentId([FromBody] RentDetail rent) { var rents = _repository.GetByRentId(rent.RentId); return(new JsonResult(rents)); }
public IResult Delete(RentDetail rentDetail) { _rentDetailDal.Delete(rentDetail); return(new SuccessResult(Messages.RentDeleted)); }
// return add event private void dataGridViewRented_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { // active return activeReturn(); // get current row DataGridViewRow row = dataGridViewRented.CurrentRow; detail = new RentDetail(); detail.RentID = int.Parse(row.Cells[1].Value.ToString()); detail.IndCanoeID = int.Parse(row.Cells[7].Value.ToString()); DataRow[] rows = rtable.Select("RentID=" + detail.RentID + " AND IndCanoeID=" + detail.IndCanoeID); foreach (DataRow d in rows) { rtemp.ImportRow(d); } dataGridViewReturn.DataSource = rtemp; dataGridViewRented.Rows.RemoveAt(row.Index); // dispaly displayRPenalty(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static void Initialize(RentContext context) { context.Database.EnsureCreated(); if (context.Regions.Any()) { return; } var regions = new Region[] { new Region { Name = "Alatau", Tax = 24 }, new Region { Name = "Medeu", Tax = 33 }, new Region { Name = "Turksyb", Tax = 12 }, new Region { Name = "Bostandyk", Tax = 19 }, }; foreach (Region r in regions) { context.Regions.Add(r); } context.SaveChanges(); var apartments = new Apartment[] { new Apartment { Address = "Akniyet 2/4/42", RegionID = 1, Price = 150000 }, new Apartment { Address = "Akniyet 2/15/27", RegionID = 1, Price = 140000 }, new Apartment { Address = "Aisulu 1/12/22", RegionID = 1, Price = 178000 }, new Apartment { Address = "Aisulu 3/10/2", RegionID = 1, Price = 120000 }, new Apartment { Address = "Aisulu 1/8/65", RegionID = 1, Price = 130000 }, new Apartment { Address = "Titanik 5/13/88", RegionID = 2, Price = 85000 }, new Apartment { Address = "Titanik 5/4/53", RegionID = 2, Price = 100000 }, new Apartment { Address = "Zhas Kanat 1/3/45", RegionID = 2, Price = 95000 }, new Apartment { Address = "Zhas Kanat 1/5/71", RegionID = 2, Price = 90000 }, new Apartment { Address = "Tengiz 1/3/38", RegionID = 2, Price = 92000 }, new Apartment { Address = "Zhibek 3/34/4", RegionID = 3, Price = 67000 }, new Apartment { Address = "Zhibek 1/68/2", RegionID = 3, Price = 55000 }, new Apartment { Address = "Besagash 5/7/66", RegionID = 3, Price = 88000 }, new Apartment { Address = "Serpin 7/10/17", RegionID = 3, Price = 69000 }, new Apartment { Address = "Tarbagatay 4/7/33", RegionID = 3, Price = 64500 }, new Apartment { Address = "Aidyn 4/1/15", RegionID = 4, Price = 75000 }, new Apartment { Address = "Aidyn 4/1/16", RegionID = 4, Price = 85000 }, new Apartment { Address = "Ak Kent 7/3/45", RegionID = 4, Price = 80000 }, new Apartment { Address = "Ak Kent 7/5/71", RegionID = 4, Price = 77000 }, new Apartment { Address = "Ak Kent 7/3/22", RegionID = 4, Price = 85000 }, }; foreach (Apartment a in apartments) { context.Apartments.Add(a); } context.SaveChanges(); var customers = new Customer[] { new Customer { Username = "******", Password = "******" }, new Customer { Username = "******", Password = "******" }, new Customer { Username = "******", Password = "******" }, }; foreach (Customer c in customers) { context.Customers.Add(c); } context.SaveChanges(); var rents = new Rent[] { new Rent { CustomerID = 5, TotalPrice = 550000 }, }; foreach (Rent r in rents) { context.Rents.Add(r); } context.SaveChanges(); var rentDetails = new RentDetail[] { new RentDetail { RentID = 1, ApartmentID = 1 }, new RentDetail { RentID = 1, ApartmentID = 2 }, new RentDetail { RentID = 1, ApartmentID = 3 }, }; foreach (RentDetail rd in rentDetails) { context.RentDetails.Add(rd); } context.SaveChanges(); }
// get rent private ArrayList getRetrunList() { try { manage.returnlist = new ArrayList(); foreach (DataGridViewRow row in dataGridViewReturn.Rows) { detail = new RentDetail(); int id = int.Parse(row.Cells[1].Value.ToString()); int indid = int.Parse(row.Cells[7].Value.ToString()); detail = manage.searchDAORentedByID(id.ToString(), indid.ToString()); decimal penalty = decimal.Parse(row.Cells[10].Value.ToString()); detail.PenaltyAmount = penalty; Individual ind = new Individual(); ind = manage.searchDAOIndividualById(indid); detail.Ind = ind; manage.returnlist.Add(detail); } } catch (Exception) { } finally { } return manage.returnlist; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); RentDetail ds = new RentDetail(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "RentDetailDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { RentDetail ds = new RentDetail(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public static void Initialize(RentContext context) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); if (context.Regions.Any()) { return; } var regions = new Region[] { new Region { Name = "District 1", Tax = 10 }, new Region { Name = "District 2", Tax = 15 }, new Region { Name = "District 3", Tax = 30 }, new Region { Name = "District 4", Tax = 50 }, }; foreach (Region r in regions) { context.Regions.Add(r); } context.SaveChanges(); var apartments = new Apartment[] { new Apartment { Address = "Street 1", RegionID = 1, Price = 15000 }, new Apartment { Address = "Street 2", RegionID = 1, Price = 140000 }, new Apartment { Address = "Street 3", RegionID = 2, Price = 85000 }, new Apartment { Address = "Street 4", RegionID = 2, Price = 100000 }, new Apartment { Address = "Street 5", RegionID = 3, Price = 67000 }, new Apartment { Address = "Street 6", RegionID = 3, Price = 55000 }, new Apartment { Address = "Street 7", RegionID = 4, Price = 75000 }, new Apartment { Address = "Street 8", RegionID = 4, Price = 85000 }, }; foreach (Apartment a in apartments) { context.Apartments.Add(a); } context.SaveChanges(); var customers = new Customer[] { new Customer { Username = "******", Password = "******" }, new Customer { Username = "******", Password = "******" }, new Customer { Username = "******", Password = "******" }, }; foreach (Customer c in customers) { context.Customers.Add(c); } context.SaveChanges(); var rents = new Rent[] { new Rent { CustomerID = 5, TotalPrice = 550000 }, }; foreach (Rent r in rents) { context.Rents.Add(r); } context.SaveChanges(); var rentDetails = new RentDetail[] { new RentDetail { RentID = 1, ApartmentID = 1 }, new RentDetail { RentID = 1, ApartmentID = 2 }, new RentDetail { RentID = 1, ApartmentID = 3 }, }; foreach (RentDetail rd in rentDetails) { context.RentDetails.Add(rd); } context.SaveChanges(); }
public ActionResult DeleteRentDetail(int?PropertyID, int?TenantID, int?RentID, RentDetail rentObj) { rentObj = db.RentDetails.Find(RentID); db.RentDetails.Remove(rentObj); //UserAccount userObj = db.UserAccounts.Where(u => u.UserName.Equals(User.Identity.Name.ToString())).FirstOrDefault(); //UserRentDetail usrRentObj = db.UserRentDetails.Where(x => x.UserID == userObj.UserID).Where(x => x.PropertyID == PropertyID).Where(x => x.TenantID == TenantID).Where(x => x.RentID == RentID).FirstOrDefault(); //db.UserRentDetails.Remove(usrRentObj); db.SaveChanges(); return(RedirectToAction("Index", "TrackRentDetail", new { PropertyID = PropertyID, TenantID = TenantID })); }