private void DeleteUserButton_Click(object sender, RoutedEventArgs e) { var selectedItem = this.lvAuto.SelectedItem; if (selectedItem != null) { AutoEntity car = selectedItem as AutoEntity; AutoService service = new AutoService(); if (MessageBox.Show("Sei sicuro di voler eliminare \"" + car.CarName + " \" ?", "Elimina Auto", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (service.Delete(car) == 0) { MessageBox.Show("cancellato!"); this.RefreshData(); } else { MessageBox.Show("NON cancellato!"); } } else { MessageBox.Show("NON cancellato!"); } } }
public void RefreshData() { AutoService service = new AutoService(); cars = new ObservableCollection <AutoEntity>(service.GetAllCars()); this.lvAuto.ItemsSource = cars; }
public void Save() { if (CheckData()) { AutoService service = new AutoService(); if ((this.DataContext as AutoEntity).Id == -1 && !CheckDoppione()) { if (service.Add(this.DataContext as AutoEntity) == 0) { MessageBox.Show("Salvato!"); this.DataContext = new AutoEntity(); } else { MessageBox.Show("Errore durante il salvataggio!"); } } else { if (service.Update(this.DataContext as AutoEntity) == 0) { MessageBox.Show("Salvato!"); } else { MessageBox.Show("Errore durante il salvataggio!"); } } } }
public ImplCarService() { var autoContext = new CarServiceContext(); var unitOfWork = new UnitOfWork(autoContext); var autoRepository = new Repository <Auto>(unitOfWork); var clientRepository = new Repository <Client>(unitOfWork); var comandaRepository = new Repository <Comanda>(unitOfWork); var detaliuComandaRepository = new Repository <DetaliuComanda>(unitOfWork); var imagineRepository = new Repository <Imagine>(unitOfWork); var materialRepository = new Repository <Material>(unitOfWork); var mecanicRepository = new Repository <Mecanic>(unitOfWork); var operatieRepository = new Repository <Operatie>(unitOfWork); var sasiuRepository = new Repository <Sasiu>(unitOfWork); clientService = new ClientService(clientRepository, unitOfWork); autoService = new AutoService(autoRepository, unitOfWork); comandaService = new ComandaService(comandaRepository, unitOfWork); detaliuComandaService = new DetaliuComandaService(detaliuComandaRepository, unitOfWork); imagineService = new ImagineService(imagineRepository, unitOfWork); materialService = new MaterialService(materialRepository, unitOfWork); mecanicService = new MecanicService(mecanicRepository, unitOfWork); operatieService = new OperatieService(operatieRepository, unitOfWork); sasiuService = new SasiuService(sasiuRepository, unitOfWork); }
public async Task <IActionResult> Create(AutoService autoService) { if (!ModelState.IsValid) { return(View(autoService)); } if (autoService.Photo == null) { ModelState.AddModelError("Photo", "Please, select any image!"); return(View(autoService)); } if (!autoService.Photo.ContentType.Contains("image/")) { ModelState.AddModelError("Photo", "Image is not valid!"); return(View(autoService)); } autoService.Image = await autoService.Photo.SaveFileAsync(_env.WebRootPath); await _context.AutoServices.AddAsync(autoService); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
protected override void OnStart(string[] args) { //ServiceHost host = new ServiceHost(typeof(AutoService)); //default: per Call var myService = new AutoService(); host = new ServiceHost(myService); //singelton var smb = new ServiceMetadataBehavior() { HttpGetEnabled = true, HttpGetUrl = new Uri("http://localhost:3/mex") }; host.Description.Behaviors.Add(smb); host.AddServiceEndpoint(typeof(IAutoService), new NetTcpBinding(), "net.tcp://localhost:1"); host.AddServiceEndpoint(typeof(IAutoService), new NetNamedPipeBinding(), "net.pipe://localhost/autos"); host.AddServiceEndpoint(typeof(IAutoService), new BasicHttpBinding(), "http://localhost:4/"); host.AddServiceEndpoint(typeof(IAutoService), new WSHttpBinding(), "http://localhost:5/"); Binding mexBinding = MetadataExchangeBindings.CreateMexTcpBinding(); host.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, "net.tcp://localhost:1/mex"); host.Open(); }
internal static void Start() { AutoService.Add(); Status.SetState(Status.EState.Starting); Instances.ServiceData.StartTimeStamp = DateTime.Now; foreach (var ba in StartupSequence.Actions) { try { ba(); } catch (Exception e) { Current.Log.Add(e); } } AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; DumpStartInfo(); Status.SetState(Status.EState.Running); }
private void AddButton_Click(object sender, EventArgs e) { Control btn = (Control)sender; Auto openautomobile = new Auto(); try { AutoService service = new AutoService(Model.Automobiles); openautomobile = service.automobileSearch(btn.Name); if (openautomobile.Enable) { ClientList clientList = new ClientList(true, openautomobile); clientList.Show(); } else { MessageBox.Show("Автомобиля нет в наличии.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { MessageBox.Show("Вы пытаетесь добавить несуществующий автомобиль", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonDeleteDerdataRelationInfo_Click(object sender, EventArgs e) { int count = dataGridView1.Rows.Count; AutoService autoTotalService = new AutoService(); try { for (int i = 0; i < count; i++) { string Id; DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dataGridView1.Rows[i].Cells[0]; Boolean flag = Convert.ToBoolean(checkCell.Value); if (flag == true) { ///赋值 Id = this.dataGridView1.Rows[i].Cells[1].Value.ToString(); bool deleteResult = autoTotalService.ServiceDeleteDerdataRelationInfo(Id); if (deleteResult == true) { MessageBox.Show("删除成功"); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public ActionResult ContactsRequestIncrement(int autoID) { string result = "error#" + Resource.UnknownError; Auto auto = AutoService.GetPublishedByID(autoID); if (auto == null) { result = "error#" + Resource.NotFound; } else { try { ContactsRequest request = new ContactsRequest() { AutoID = autoID, UserID = auto.UserID }; ContactsRequestService.Create(request); result = "success#1"; } catch (Exception ex) { result = "error#" + ex.Message; } } return(Json(result)); }
public ActionResult AddAuto(string Make, string Model, int Year, string VIN, int clientId) { var auto = new Auto() { Make = Make, Model = Model, Year = Year, VIN = VIN }; AutoService.AddAuto(auto, clientId); return(GetAccount(clientId)); }
public void AutosPorEstado() { var mockDb = new Mock <ExamenContext>(); mockDb.Setup(o => o.Autos).Returns(Autos.GetDbSet()); var service = new AutoService(mockDb.Object); var result = service.getAuto(null, null, null, "nuevo", null, null); Assert.AreEqual(12, result.LongCount()); }
public void AutosMarcaAudi() { var mockDb = new Mock <ExamenContext>(); mockDb.Setup(o => o.Autos).Returns(Autos.GetDbSet()); var service = new AutoService(mockDb.Object); var result = service.getAuto("Audi", null, null, null, null, null); Assert.AreEqual(4, result.LongCount()); }
public void TodoslosAutos() { var mockDb = new Mock <ExamenContext>(); mockDb.Setup(o => o.Autos).Returns(Autos.GetDbSet()); var service = new AutoService(mockDb.Object); var result = service.getAuto(); Assert.AreEqual(18, result.LongCount()); }
public void AutosPorPrecioMaximo() { var mockDb = new Mock <ExamenContext>(); mockDb.Setup(o => o.Autos).Returns(Autos.GetDbSet()); var service = new AutoService(mockDb.Object); var result = service.getAuto(null, null, null, null, null, 50000); Assert.AreEqual(11, result.LongCount()); }
public Form1() { InitializeComponent(); autoService = new AutoService(); Task.Run(async() => { autos = await autoService.GetAll(); await Task.Delay(1000); this.Invoke(new MethodInvoker(() => pictureBoxLoading.Hide())); autos.ForEach(a => AddAutoToList(a)); }); }
public async Task <IActionResult> Delete(int?id) { if (id == null) { NotFound(); } AutoService autoService = await _context.AutoServices.FindAsync(id); if (autoService == null) { NotFound(); } return(View(autoService)); }
private bool CheckDoppione() { string carName = (this.DataContext as AutoEntity).CarName.ToLower(); AutoService service = new AutoService(); List <AutoEntity> cars = service.GetAllCars(); if (cars.Any(x => x.CarName.ToLower().Equals(carName))) { return(true); } return(false); }
public ActionResult AddExchangeOffer(AddExchangeOfferVM model) { Auto targetAuto = AutoService.GetPublishedByID(model.TargetAutoID); if (targetAuto == null) { return(HttpNotFound()); } User currentUser = UserService.GetUserByEmail(User.Identity.Name); AutoExchangeDetailsVM exchangeDetailsVM = null; try { AutoExchange newExchange = new AutoExchange() { OfferedAutoID = model.OfferedAutoID, TargetAutoID = model.TargetAutoID, DateCreated = DateTime.Now, CurrencyID = model.CurrencyID, DiffPrice = model.DiffPrice, DiffPriceDirection = model.DiffPriceDirection }; AutoExchangeService.Create(newExchange); Currency currency = CurrencyService.GetByID(newExchange.CurrencyID); Auto offeredAuto = AutoService.GetByID(model.OfferedAutoID); exchangeDetailsVM = targetAuto.AutoExchangesIncome.FirstOrDefault(ex => ex.ID == newExchange.ID); if (exchangeDetailsVM != null) { exchangeDetailsVM.Currency = currency.Symbol; exchangeDetailsVM.DeleteButtonIsAvailable = (currentUser != null && (currentUser.ID == offeredAuto.UserID || currentUser.ID == offeredAuto.UserID)); } } catch (Exception ex) { ViewBag.errorMsg = "Error: " + ex.Message; } return(PartialView("_ExchangeOffer", exchangeDetailsVM)); }
public IHttpActionResult DeletePhoto(int autoID, int photoID) { try { User user = UserService.GetUserByEmail(User.Identity.Name); Auto auto = AutoService.GetByID(autoID); if (auto == null || auto.UserID != user.ID) { return(NotFound()); } int mainPhotoID = AutoPhotoService.Delete(photoID); return(Ok(mainPhotoID)); } catch (Exception ex) { return(InternalServerError(ex)); } }
static void Main(string[] args) { var autoContext = new CarServiceContext(); var unitOfWork = new UnitOfWork(autoContext); var autoRepository = new Repository <Auto>(unitOfWork); var clientRepository = new Repository <Client>(unitOfWork); var sasiuRepository = new Repository <Sasiu>(unitOfWork); var clientService = new ClientService(clientRepository, unitOfWork); var autoService = new AutoService(autoRepository, unitOfWork); var sasiuService = new SasiuService(sasiuRepository, unitOfWork); var sasiuDto = new SasiuDto { Denumire = "Fara Denumire", CodSasiu = "8D" }; var updateSasiu = sasiuService.FindById(3); updateSasiu.CodSasiu = "8D"; //sasiuService.CreateNew(sasiuDto); sasiuService.Update(updateSasiu); /*var client = new ClientDto * { * Nume = "Nume1", * Prenume = "Prenume1", * Email = "*****@*****.**", * Adresa = "Adresa1", * Judet = "Judet1", * Localitate = "Localitate1" * };*/ //clientService.CreateNew(client); //clientService.Delete(5); }
public static IApplicationBuilder UseZen(this IApplicationBuilder app, Action <IZenBuilder> configuration = null, IHostEnvironment env = null) { configuration = configuration ?? (x => { }); Instances.ApplicationBuilder = app; var optionsProvider = app.ApplicationServices.GetService <IOptions <ZenOptions> >(); var options = new ZenOptions(optionsProvider.Value); AutoService.UseAll(app, env); var builder = new ZenBuilder(app, options); configuration.Invoke(builder); Current.State = Status.EState.Running; Current.Log.Add(Current.State.ToString(), Message.EContentType.StartupSequence, Host.ApplicationAssemblyName); return(app); }
public async Task <IActionResult> Edit(int?id, AutoService autoService) { if (!ModelState.IsValid) { return(View(autoService)); } AutoService autoServicedb = await _context.AutoServices.FindAsync(id); if (autoService.Photo != null) { if (autoService.Photo.ContentType.Contains("image/")) { string path = _env.WebRootPath + @"\image\" + autoServicedb.Image; if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } autoServicedb.Image = await autoService.Photo.SaveFileAsync(_env.WebRootPath); } else { ModelState.AddModelError("Photo", "Selected image is not valid!"); return(View(autoService)); } } autoServicedb.CompanyName = autoService.CompanyName; autoServicedb.Phone = autoService.Phone; autoServicedb.SecondaryPhone = autoService.SecondaryPhone; autoServicedb.Email = autoService.Email; autoServicedb.Address = autoService.Address; autoServicedb.Description = autoService.Description; autoServicedb.Facebook = autoService.Facebook; autoServicedb.Instagram = autoService.Instagram; autoServicedb.Youtube = autoService.Youtube; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> DeletePost(int?id) { if (id == null) { NotFound(); } AutoService autoService = await _context.AutoServices.FindAsync(id); if (autoService == null) { NotFound(); } string path = _env.WebRootPath + @"\image\" + autoService.Image; if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } _context.AutoServices.Remove(autoService); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
//[ResponseType(typeof(Model.City))] public IHttpActionResult AddToFavorites(int id) { User user = UserService.GetUserByEmail(User.Identity.Name); Auto auto = AutoService.GetByID(id); if (auto == null) { return(NotFound()); } try { int result = 1; AutoFavorite fav = user.AutoFavorites.FirstOrDefault(f => f.AutoID == id); if (fav == null) { user.AutoFavorites.Add(new AutoFavorite() { AutoID = id }); UserService.EditUser(user); } else { AutoFavoriteService.Delete(fav); result = -1; } AutoService.Edit(auto); return(Ok(result)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public IHttpActionResult UploadPhoto(int autoID, HttpPostedFileBase photo) { try { User user = UserService.GetUserByEmail(User.Identity.Name); Auto auto = AutoService.GetByID(autoID); if (auto == null || auto.UserID != user.ID) { return(NotFound()); } int photoID = AutoPhotoService.UploadPhoto(autoID, photo); if (photoID == 0) { throw new Exception("Save error"); } return(Ok(photoID)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public ActionResult DeleteAuto(int autoId, int clientId) { AutoService.DeleteAuto(autoId); return(GetAccount(clientId)); }
public ActionResult RefreshAuto() { ViewBag.cars = AutoService.GetCars(); return(PartialView("_Cars")); }
public ActionResult Index() { ViewBag.orders = OrderService.GetOrders(); ViewBag.cars = AutoService.GetCars(); return(View()); }
private void ReadyButton_Click(object sender, EventArgs e) { try { Model.ThisAutoModel.Mark.Equals(""); if (ProductYearMaskedTextBox.MaskFull && ColorTextBox.TextLength != 0 && MileAgeTextBox.TextLength != 0 && Convert.ToInt32(ProductYearMaskedTextBox.Text.Remove(5, 2)) <= DateTime.Today.Date.Year && Convert.ToInt32(ProductYearMaskedTextBox.Text.Remove(5, 2)) >= 1700 && DescriptionTextBox.TextLength != 0) { String transmission; if (MechTrRadioButton.Checked) { transmission = "механическая"; } else if (VarTrRadioButton.Checked) { transmission = "вариативная"; } else if (AutTrRadioButton.Checked) { transmission = "автоматическая"; } else { transmission = "роботизированная"; } if (FlagFrom && Model.Automobiles.Count == Model.CarsAmount) { Model.CarsAmount++; } Auto autoautomobile = new Auto(Convert.ToInt32(ProductYearMaskedTextBox.Text.Remove(4, 3)), ColorTextBox.Text, MileAgeTextBox.Text, Model.Automobiles.Count + 1, PhotoPictureBox.Image, transmission, DescriptionTextBox.Text, Model.ThisAutoModel); AutoService service = new AutoService(Model); autoautomobile.ID = service.generateID(); service.automobileRegistration(autoautomobile); MessageBox.Show("Новый автомобиль успешно добавлен.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { if (Convert.ToInt32(ProductYearMaskedTextBox.Text.Remove(5, 2)) > DateTime.Today.Date.Year || Convert.ToInt32(ProductYearMaskedTextBox.Text.Remove(5, 2)) <= 1700) { ErrorProvider.SetError(ProductYearMaskedTextBox, "проверьте введенный год"); } if (ColorTextBox.TextLength == 0) { ColorTextBox.BackColor = Color.IndianRed; } if (MileAgeTextBox.TextLength == 0) { MileAgeTextBox.BackColor = Color.IndianRed; } if (!ProductYearMaskedTextBox.MaskFull) { ProductYearMaskedTextBox.BackColor = Color.IndianRed; } if (PhotoPictureBox.Image == null) { PhotoPictureBox.BackColor = Color.IndianRed; } if (!MechTrRadioButton.Checked && !AutTrRadioButton.Checked && !VarTrRadioButton.Checked && !RobTrRadioButton.Checked) { TransmissionErrorProvider.SetError(TransmissiomLabel, "Выберите тип коробки передач"); } if (DescriptionTextBox.TextLength == 0) { DescriptionTextBox.BackColor = Color.IndianRed; } } } catch (NullReferenceException) { MessageBox.Show("Вы пытаетесь добавить автомобиль несуществующей модели", " ", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }