protected void lvChitietSanpham_ItemCommand(object sender, ListViewCommandEventArgs e) { ///Khi nguwoif dùng ấn vào thêm giỏ hàng thì dữ liệu đc chuyển sang giỏ hàng if (e.CommandName == "Them") { int id = Convert.ToInt32(e.CommandArgument); if (id > 0) { TextBox txtSoluong = e.Item.FindControl("txtSoluong") as TextBox; int soluong = Convert.ToInt32(txtSoluong.Text); List <Products> n_product = (List <Products>)Application["products"]; List <CarEntity> glstCar = (List <CarEntity>)Session["cartItem"]; CarEntity cart = new CarEntity(); n_product = n_product.FindAll(sp => sp.Id == id); cart.Id = n_product[0].Id; // gán id bằng id sản phẩm tìm đc trong danh sách cart.Path = n_product[0].Link; // gán link ảnh bằng link ảnh sản phẩm tìm đc trong danh sách cart.Name = n_product[0].Name; // gán tên sp bằng tên sp sản phẩm tìm đc trong danh sách cart.Price = n_product[0].Price; // gán giá bằng giá sản phẩm tìm đc trong danh sách cart.Count = soluong; // số lượng số lượng chọn trên textbox cart.TotalPrices = cart.Price * cart.Count; //tổng tiền glstCar.Add(cart); // thêm vào giỏ hàng if (cart.Count > 0) { Response.Write("<script> alert('Thêm thành công!');</script>"); Response.Write("<script>window.location='/product.aspx';</script>"); } } } }
public void AddOrUpdateCar(CarDTO car) { var carEntity = new CarEntity(); if (car.IdCar != 0) { carEntity = _carOwnerContext.Cars.Find(car.IdCar); carEntity.DescriptionCar.Description = car.DescriptionCar.Description; } else { carEntity.DescriptionCar = new DescriptionCarEntity() { Description = car.DescriptionCar.Description, ImageData = car.DescriptionCar.ImageData, ImageMineType = car.DescriptionCar.ImageMineType }; } if (car.DescriptionCar.ImageData != null) { carEntity.DescriptionCar.ImageData = car.DescriptionCar.ImageData; carEntity.DescriptionCar.ImageMineType = car.DescriptionCar.ImageMineType; } carEntity.IdCar = car.IdCar; carEntity.Model = car.Model; carEntity.Price = car.Price; carEntity.YearRelease = car.YearRelease; carEntity.TypeCar = (byte)car.TypeCar; carEntity.СarMake = car.СarMake; _carOwnerContext.Cars.AddOrUpdate(carEntity); }
static void Main(string[] args) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json"); Configuration = builder.Build(); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Configuration["StorageConnectionString"]); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference("Assignment3Table"); table.CreateIfNotExistsAsync().GetAwaiter().GetResult(); CarEntity newcar = new CarEntity("WBA3B5C5XDF595354"); newcar.Make = "BMW"; newcar.Model = "3 SERIES"; newcar.Color = "Grey"; TableOperation insertOperation = TableOperation.Insert(newcar); table.ExecuteAsync(insertOperation).GetAwaiter().GetResult(); }
public void RemoveCarTest() { Car car = new Car(); car.StateNumber = "1234-AA7"; using (ParkingDBContext context = contextFactory.CreateDbContext()) { ApplicationUser userEntity = new ApplicationUser(); userEntity.UserName = "******"; CarEntity carEntity = new CarEntity(); carEntity.StateNumber = car.StateNumber; context.Users.Add(userEntity); context.Cars.Add(carEntity); car.Id = carEntity.IdCar; UsersHaveCars uhc = new UsersHaveCars(); uhc.UserEntity = userEntity; uhc.CarEntity = carEntity; userEntity.UsersHaveCars = new List <UsersHaveCars>(); userEntity.UsersHaveCars.Add(uhc); context.SaveChanges(); } CarManager carManager = new CarManager(contextFactory); bool removedCar = carManager.RemoveCar(car); Assert.True(removedCar); }
public static List <CarEntity> GetAllCar(string carid, string supplierid) { List <CarEntity> all = new List <CarEntity>(); CarRepository mr = new CarRepository(); string KEY = "CarALL"; if (!string.IsNullOrEmpty(carid)) { KEY += "CARID" + carid; } if (!string.IsNullOrEmpty(supplierid)) { KEY += "SUPPLIERID" + supplierid; } List <CarInfo> miList = Cache.Get <List <CarInfo> >(KEY); if (miList.IsEmpty()) { miList = mr.GetAllCarInfo(carid, supplierid); Cache.Add(KEY, miList); } if (!miList.IsEmpty()) { foreach (CarInfo mInfo in miList) { CarEntity carEntity = TranslateCarEntity(mInfo); all.Add(carEntity); } } return(all); }
public void WhenCreate_ThenReturnsCar() { var person = new Person { Id = "apersonid" }; this.personService.Setup(ps => ps.Get(It.IsAny <string>())) .Returns(person); var make = Manufacturer.Makes[0]; var model = Manufacturer.Models[0]; var entity = new CarEntity(this.recorder.Object, this.idFactory.Object); this.storage.Setup(s => s.Save(It.IsAny <CarEntity>())) .Returns(entity); var result = this.carsApplication.Create(this.caller.Object, 2010, make, model); result.Id.Should().Be("anid"); this.storage.Verify(s => s.Save(It.Is <CarEntity>(e => e.Owner == "apersonid" && e.Manufacturer.Year == 2010 && e.Manufacturer.Make == make && e.Manufacturer.Model == model && e.Managers.Managers.Single() == "apersonid"))); }
public static String commerce() { UpdatedCar newCar = Access.sHttp.getPostData().DeserializeObject <CommerceSessionTrans>().updatedCar; CommerceSessionResultTrans commerceSessionResultTrans = new CommerceSessionResultTrans(); UpdatedCar responseCar = new UpdatedCar(); using (var session = SessionManager.getSessionFactory().OpenSession()) using (var transaction = session.BeginTransaction()) { CarEntity carEntity = session.Load <CarEntity>(Access.CurrentSession.ActivePersona.SelectedCar.Id); carEntity.vinyls = newCar.customCar.vinyls; carEntity.paints = newCar.customCar.paints; carEntity.performanceParts = newCar.customCar.performanceParts; carEntity.skillModParts = newCar.customCar.skillModParts; carEntity.visualParts = newCar.customCar.visualParts; carEntity.heatLevel = 1; responseCar.customCar = CustomCar.getCustomCar(carEntity); responseCar.durability = carEntity.durability; responseCar.heatLevel = 1; responseCar.id = carEntity.id; responseCar.ownershipType = "CustomizedCar"; session.Update(carEntity); transaction.Commit(); } commerceSessionResultTrans.updatedCar = responseCar; return(commerceSessionResultTrans.SerializeObject()); }
public async Task <CarEntity> CreateCarAsync(CarEntity newCar) { if (newCar.Id == Guid.Empty.ToString()) { newCar.Id = Guid.NewGuid().ToString(); } var dnow = DateTime.UtcNow; newCar.CreatedOn = dnow; newCar.ModifiedOn = dnow; const string sqlQuery = @"INSERT INTO cars ( id, modelname, cartype, createdon, modifiedon ) VALUES ( @id, @modelname, @cartype, @createdon, @modifiedon);"; using (var db = new MySqlConnection(_options.CurrentValue.CarsDbConnectionString)) { await db.ExecuteAsync(sqlQuery, newCar, commandType : CommandType.Text); return(newCar); } }
public HttpResponseMessage update(CarEntity carEntity) { try { var response = new HttpResponseMessage(HttpStatusCode.OK); var currentCar = db.Cars.SingleOrDefault(p => p.CarNumber == carEntity.carNumber); currentCar.CarNumber = carEntity.carNumber; currentCar.CarType = carEntity.carType; currentCar.IsAvailable = carEntity.isAvailable; currentCar.IsUndamaged = carEntity.isUndamaged; currentCar.Mileage = carEntity.mileage; //currentCar.BranchID = carEntity.branchId; currentCar.Image = carEntity.image; db.SaveChanges(); return(response); } catch { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
protected override void OnEnter() { GetElementById("Ok").Click += Ok_Click; GetElementById("Return").Click += Return_Click; _passangerList = new List <PassangerData>(); _carEntity = GetBusinessEntity <CarEntity>(); TicketLines line = _carEntity.SelectLine; GetElementById("bus_type_name").InnerText = line.BusTypeName; GetElementById("sch_id").InnerText = line.SchId; GetElementById("service_price").InnerText = line.ServicePrice; GetElementById("mile").InnerText = line.Mile; GetElementById("full_price").InnerText = line.FullPrice; GetElementById("riding_date").InnerText = _carEntity._BstTicketByCityRequest.RidingDate; GetElementById("city").InnerText = line.City; GetElementById("carry_sta_name").InnerText = line.CarryStaName; GetElementById("drv_date_time").InnerText = line.DrvDateTime; GetElementById("sch_type_name").InnerText = line.SchTypeName; GetElementById("stop_name").InnerText = line.StopName; InitPassagerView(); GetElementById("confirm").Click += Confirm_Click; GetElementById("cancel").Click += Cancel_Click; GetElementById("passName").GotFocus += frmInput_GotFocus; GetElementById("passName").LostFocus += frmInput_LostFocus; GetElementById("cerNumValue").GotFocus += numberInput_GotFocus; GetElementById("cerNumValue").LostFocus += numberInput_LostFocus; GetElementById("passTel").GotFocus += numberInput_GotFocus; GetElementById("passTel").LostFocus += numberInput_LostFocus; }
public ActionResult DeleteConfirmed(int id) { CarEntity carEntity = _carsRepository.GetWhere(x => x.Id == id).FirstOrDefault(); _carsRepository.Delete(carEntity); return(RedirectToAction("Index")); }
public async Task <string> AddCar(string name, CarDto carDto) { var foundParkingLotEntity = await this.parkingLotDbContext.ParkingLots .Include(parkingLot => parkingLot.Cars) .Include(parkingLot => parkingLot.Orders) .FirstOrDefaultAsync(parkingLotEntity => parkingLotEntity.Name == name); if (foundParkingLotEntity != null) { var leftPosition = foundParkingLotEntity.Capacity - this.parkingLotDbContext.Cars.Count(); if (leftPosition > 0) { CarEntity newCarEntity = new CarEntity(carDto); await this.parkingLotDbContext.Cars.AddAsync(newCarEntity); await this.parkingLotDbContext.SaveChangesAsync(); return(newCarEntity.PlateNumber); } return("The parking lot is full."); } return("The parking lot is not exist."); }
public Car AddCar(Car car, string username) { if (car == null) { throw new ArgumentNullException(); } if (string.IsNullOrWhiteSpace(username)) { throw new ArgumentNullException(username); } using (ParkingDBContext context = factory.CreateDbContext()) { ApplicationUser userEntity = context.Users.Single(us => us.UserName == username); CarEntity carEntity = new CarEntity(); carEntity.Manufacturer = car.Manufacturer; carEntity.Model = car.Model; carEntity.StateNumber = car.StateNumber; carEntity.Year = car.Year; carEntity.Color = car.Color; context.Cars.Add(carEntity); UsersHaveCars uhc = new UsersHaveCars(); uhc.UserEntity = userEntity; uhc.CarEntity = carEntity; carEntity.UsersHaveCars = new List <UsersHaveCars>(); carEntity.UsersHaveCars.Add(uhc); context.SaveChanges(); return(car); } }
public void GetParkedCarsTest() { string username = "******"; using (ParkingDBContext context = contextFactory.CreateDbContext()) { ApplicationUser user = new ApplicationUser(); user.UserName = username; CarEntity firstCar = new CarEntity(); firstCar.StateNumber = "1515-IO7"; context.Users.Add(user); UsersHaveCars uhc = new UsersHaveCars(); uhc.UserEntity = user; uhc.CarEntity = firstCar; user.UsersHaveCars = new List <UsersHaveCars>(); user.UsersHaveCars.Add(uhc); ParkingHistoryEntity parkingHistoryEntity = new ParkingHistoryEntity(); parkingHistoryEntity.IdCar = firstCar.IdCar; parkingHistoryEntity.IdUser = user.Id; parkingHistoryEntity.IdParking = 1; parkingHistoryEntity.Arrival = DateTime.Now; parkingHistoryEntity.Car = firstCar; parkingHistoryEntity.User = user; context.ParkingHistory.Add(parkingHistoryEntity); context.SaveChanges(); } CarManager carManager = new CarManager(contextFactory); List <Car> cars = carManager.GetParkedCars(username); Assert.NotEmpty(cars); }
public JsonResult GetCars() { CarEntity carEntity = new CarEntity(); var model = carEntity.Cars(); return(Json(model, JsonRequestBehavior.AllowGet)); }
public void PostFail() { var carServices = new Mock <ICarServices>(); var logger = new Mock <ILogger <CarController> >(); carServices.Setup(x => x.Insert(It.IsAny <CarEntity>())); var carController = new CarController(carServices.Object, logger.Object); var carEntity = new CarEntity { Brand = "t", Model = "t", Year = "2" }; var response = carController.Insert(carEntity); Assert.NotNull(response); Assert.IsType <BadRequestObjectResult>(response.Result); var httpObjResult = response.Result as BadRequestObjectResult; Assert.NotNull(httpObjResult); Assert.True(httpObjResult.StatusCode == 401); var value = httpObjResult.Value; Assert.NotNull(value); Assert.False(string.IsNullOrWhiteSpace(value.ToString())); Assert.Same("success", value); }
public Car CarUpdate(Car car) { if (car == null) { throw new ArgumentNullException(); } using (ParkingDBContext context = factory.CreateDbContext()) { CarEntity carEntity = context.Cars.Single(c => c.IdCar == car.Id); carEntity.StateNumber = car.StateNumber; carEntity.Manufacturer = car.Manufacturer; carEntity.Model = car.Model; carEntity.Color = car.Color; carEntity.Year = car.Year; context.Cars.Update(carEntity); int number = context.SaveChanges(); if (number == 0) { throw new InvalidOperationException(); } return(car); } }
public FetchSpecs(SqLiteNHibernateFixture fixture) : base(fixture) { using (var tx = Session.BeginTransaction()) { var person = new PersonEntity(); CarEntity car; car = new CarEntity{Owner = person}; person.Cars.Add(car); car = new CarEntity{Owner = person}; person.Cars.Add(car); PetEntity pet; pet = new PetEntity {Owner = person}; person.Pets.Add(pet); pet = new PetEntity {Owner = person}; person.Pets.Add(pet); var employer = new EmployerEntity(); Session.Save(employer); employer.Employees.Add(person); person.Employer = employer; Session.Save(person); tx.Commit(); } Session.Clear(); SessionFactory.Statistics.Clear(); }
protected override void OnEnter() { DestroySelf();//设置成自动销毁,每次重新生成 bemvInit = false; bisICCard = false; entity = GetBusinessEntity <CarEntity>(); if (CommonData.UserCardType == UserBankCardType.ICCard || CommonData.UserCardType == UserBankCardType.IcMagCard) { bisICCard = true; } if (SyncTransaction(new CReverse_YAPaymentPay()) == TransResult.E_RECV_FAIL) { entity.UnlockMessage = "交易超时,请重试,"; StartActivity("解锁车票"); return; } entity.SendField55 = null; if (bisICCard)//如果是IC卡,或是复合卡 { PostSync(EMVProcess); if (!bemvInit) { entity.UnlockMessage = "IC卡初始化失败,请重试,"; StartActivity("解锁车票"); return; } } PayProcess(); }
public async Task <OrderDto?> AddOrder(OrderRequestDto orderRequestDto) { var parkingLots = await parkingLotDbContext.ParkingLots.ToListAsync(); if (parkingLots.Any(parkingLot => parkingLot.Cars.Any(car => car.PlateNumber == orderRequestDto.PlateNumber))) { return(null); } var parkingLot = parkingLots.FirstOrDefault(parkingLot => parkingLot.Name == orderRequestDto.ParkingLotName); if (parkingLot.Capacity > parkingLot.Cars.Count) { var carEntity = new CarEntity(); carEntity.PlateNumber = orderRequestDto.PlateNumber; carEntity.ParkingLotEntity = parkingLot; carEntity.ParkingLotId = parkingLot.Id; parkingLot.Cars.Add(carEntity); //await parkingLotDbContext.Cars.AddAsync(carEntity); var orderDto = new OrderDto(orderRequestDto); var orderEntity = new OrderEntity(orderDto); orderEntity.Status = "Created"; await this.parkingLotDbContext.Orders.AddAsync(orderEntity); await this.parkingLotDbContext.SaveChangesAsync(); return(orderDto); } return(null); }
public HttpResponseMessage create(CarEntity carEntity) { try { var response = new HttpResponseMessage(HttpStatusCode.OK); var car = new Car() { //id = rentalEntity.id, CarNumber = carEntity.carNumber, CarType = carEntity.carType, IsAvailable = carEntity.isAvailable, IsUndamaged = carEntity.isUndamaged, Mileage = carEntity.mileage, BranchID = carEntity.branchId, Image = carEntity.image }; db.Cars.Add(car); db.SaveChanges(); return(response); } catch { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public static bool ModifyCar(CarEntity car) { int result = 0; if (car != null) { CarRepository mr = new CarRepository(); CarInfo carInfo = TranslateCarInfo(car); if (car.CarID > 0) { carInfo.ModifyDate = DateTime.Now; result = mr.ModifyCarInfo(carInfo); } else { carInfo.CreateDate = DateTime.Now; carInfo.ModifyDate = DateTime.Now; result = mr.CreateNewCarInfo(carInfo); } List <CarInfo> miList = mr.GetAllCarInfo();//刷新缓存 Cache.Add("CarALL", miList); } return(result > 0); }
public virtual bool CheckBookingNo(BookingEntity booking, CarEntity car) { if (booking.CarKey == car.CarKey) { return(true); } return(false); }
public void PriceGetterSetterIncorrectTest() { var car = new CarEntity(); var incorrectBrandName = "IncorrectBrand"; car.SetBrandName("CorrrectBrand"); Assert.AreNotEqual(car.GetBrandName(), incorrectBrandName); }
public void BrandNameGetterSetterCorrectTest() { var car = new CarEntity(); var testBrandName = "CorrectBrand"; car.SetBrandName(testBrandName); Assert.AreEqual(car.GetBrandName(), testBrandName); }
public void PriceGetterSetterCorrectTest() { var car = new CarEntity(); var testPrice = 17748; car.SetPrice(testPrice); Assert.AreEqual(car.GetPrice(), testPrice); }
public string SaveCarAndGenerateCarKeyIfNull(CarEntity carEntity) { if (carEntity.ID == 0) { _carRepository.Insert(carEntity); } return(carEntity.CarKey); }
public void DateGetterSetterIncorrectTest() { var car = new CarEntity(); var testDate = new DateTime(2017, 11, 27); car.SetDate(new DateTime(2017, 11, 28)); Assert.AreNotEqual(car.GetDate(), testDate); }
protected override void OnEnter() { _carEntity = GetBusinessEntity <CarEntity>(); worker = new BackgroundWorker(); worker.DoWork += worker_DoWork; worker.RunWorkerCompleted += worker_RunWorkerCompleted; worker.RunWorkerAsync(); }
public async Task UpdateCar(IOperation operation, CarEntity entity) { if (!await carStore.IsExist(operation, entity.Id)) { throw new Exception(ExceptionMessage.CarIsNotExist); } await carStore.Update(operation, entity); }
public void DeleteCar(CarEntity car) { var DeleteAction = new Action() { Car = car, Type = ActionType.Delete }; Actions.Add(DeleteAction); }
public void AddCar(string fileName, CarEntity car) { var AddAction = new Action() { Car=car, FileName = fileName, Type = ActionType.Add }; Actions.Add(AddAction); }
public bool HasCar(CarEntity car) { return this.m_association.Contains(car); }
public void EditCar(CarEntity car) { //parameter is not needed now. _hasWork = true; }
public void AddCar(CarEntity car) { this.m_association.Add(car); }
public void RemoveCar(CarEntity car) { this.m_association.Remove(car); }