public IQueryable <T> Query <T>() where T : Model.Entity { if (typeof(T) == typeof(Lieferant)) { var l1 = new Lieferant() { Name = "L1" }; l1.Gerichte.Add(new Gericht() { Name = "G1", KCal = 37 }); l1.Gerichte.Add(new Gericht() { Name = "G2", KCal = 100 }); var l2 = new Lieferant() { Name = "L2" }; l2.Gerichte.Add(new Gericht() { Name = "G1", KCal = 237 }); l2.Gerichte.Add(new Gericht() { Name = "G2", KCal = 200 }); return(new[] { l1, l2 }.Cast <T>().AsQueryable()); } throw new NotImplementedException(); }
public ActionResult Delete(string[] lieferantenIds) { try { if (User != null && User.Identity.IsAuthenticated) { int userId = ((CustomPrincipal)User).UserId; using (ApplicationDbContext context = new ApplicationDbContext()) { IEnumerable <Lieferant> lieferanten = new List <Lieferant>(); for (int i = 0; i < lieferantenIds.Length; i++) { Lieferant lieferant = context.GetLieferantById(int.Parse(lieferantenIds[i])); if (lieferant != null) { context.DeleteLieferant(lieferant); } } } } } catch (Exception e) { Log.Error(e.Message); return(new HttpStatusCodeResult(System.Net.HttpStatusCode.InternalServerError, "Beim Löschen der Lieferanten ist ein Fehler aufgetreten.")); } return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK)); }
public ActionResult Details(int lieferantenId) { try { Lieferant lieferant = null; //Lieferant abfragen using (ApplicationDbContext context = new ApplicationDbContext()) { lieferant = context.GetLieferantById(lieferantenId); if (lieferant != null) { return(PartialView("~/Views/Lieferanten/_LieferantenDetail.cshtml", lieferant)); } else { return(new HttpNotFoundResult("Lieferant mit Id " + lieferantenId + " nicht gefunden")); } } } catch (Exception e) { Log.Error(e.Message); return(new HttpStatusCodeResult(System.Net.HttpStatusCode.InternalServerError, "Bei der Abfrage des Lieferanten mit Id " + lieferantenId + " ist ein Fehler aufgetreten.")); } }
/// <summary> /// Erzeugt eine neue Instanz der BestellungListView(); /// </summary> public BestellungListView(Lieferant lieferant) { InitializeComponent(); this.myLieferant = lieferant; this.InitializeData(); Application.Idle += this.Application_Idle; }
public ActionResult Details(Lieferant Lieferant) { try { using (ApplicationDbContext context = new ApplicationDbContext()) { context.UpdateLieferant(Lieferant); } } catch (Exception e) { Log.Error(e.Message); return(new HttpStatusCodeResult(System.Net.HttpStatusCode.InternalServerError, "Beim Aktualiseren des Lieferanten mit Id " + Lieferant.LieferantId + " ist ein Fehler aufgetreten.")); } return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK)); }
public void GetLieferantWithMostKCal_Two_Lieferanten_second_one_has_more_KCal_MOCK_mit_Moq() { var mock = new Mock <IRepository>(); mock.Setup(x => x.Query <Lieferant>()).Returns(() => { var l1 = new Lieferant() { Name = "L1" }; l1.Gerichte.Add(new Gericht() { Name = "G1", KCal = 37 }); l1.Gerichte.Add(new Gericht() { Name = "G2", KCal = 100 }); var l2 = new Lieferant() { Name = "L2" }; l2.Gerichte.Add(new Gericht() { Name = "G1", KCal = 237 }); l2.Gerichte.Add(new Gericht() { Name = "G2", KCal = 200 }); return(new[] { l1, l2 }.AsQueryable()); }); var core = new Core(mock.Object); var result = core.GetLieferantWithMostKCal(); result.Name.Should().Be("L2"); mock.Verify(x => x.Query <Lieferant>(), Times.AtLeast(1)); }
public void GetLieferantWithMostKCal_two_Liefernaten_have_the_same_sum_of_KCal_result_L1() { var mock = new Mock <IRepository>(); mock.Setup(x => x.Query <Lieferant>()).Returns(() => { var l1 = new Lieferant() { Name = "L1" }; l1.Gerichte.Add(new Gericht() { Name = "G1", KCal = 100 }); l1.Gerichte.Add(new Gericht() { Name = "G2", KCal = 100 }); var l2 = new Lieferant() { Name = "L2" }; l2.Gerichte.Add(new Gericht() { Name = "G1", KCal = 150 }); l2.Gerichte.Add(new Gericht() { Name = "G2", KCal = 50 }); return(new[] { l1, l2 }.AsQueryable()); }); var core = new Core(mock.Object); var result = core.GetLieferantWithMostKCal(); result.Name.Should().BeNull(); }
void dgvSuppliers_RowEnter(object sender, DataGridViewCellEventArgs e) { if (this.myFormClosing) { return; } if (this.dgvSuppliers.RowCount == 0) { this.Text = "Kein Lieferant mit dem eingegebenen Filter gefunden"; return; } this.SelectedLieferant = this.dgvSuppliers.Rows[e.RowIndex].DataBoundItem as Lieferant; if (this.SelectedLieferant.Kontaktperson != null) { this.Text = string.Format("{0} [{1}] - Ansprechpartner: {2}", this.SelectedLieferant.Name1, this.SelectedLieferant.Lieferantennummer.Substring(0, 5), this.SelectedLieferant.Kontaktperson.Kontaktname); } else { this.Text = string.Format("{0} [{1}] - * Kein Ansprechpartner eingetragen *", this.SelectedLieferant.Name1, this.SelectedLieferant.Lieferantennummer.Substring(0, 5)); } this.Invalidate(); }
static void Cuetiva() { Console.WriteLine("Cuetiva"); Kunde bert = new Kunde { Name = "Bert", EMails = new List <string> { "*****@*****.**" }, Kontostand = 1234.56m }; Lieferant shop = new Lieferant { Name = "Shop", EMails = new List <string> { "*****@*****.**" }, Konto = "Sparkasse" }; var list = new List <Kontakt> { bert, shop }; foreach (var kontakt in list) { kontakt.MonatsReport(); } }
public void GetLieferantWithMostKCal_Liefernaten_have_no_Gerichte_results_null() { var mock = new Mock <IRepository>(); mock.Setup(x => x.Query <Lieferant>()).Returns(() => { var l1 = new Lieferant() { Name = "L1" }; var l2 = new Lieferant() { Name = "L2" }; return(new[] { l1, l2 }.AsQueryable()); }); var core = new Core(mock.Object); var result = core.GetLieferantWithMostKCal(); result.Name.Should().BeNull(); }
public ActionResult UploadLieferantenFile() { try { if (ModelState.IsValid) { int userId = ((CustomPrincipal)(User)).UserId; if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0) { HttpPostedFileBase file = Request.Files[0]; if (file.FileName.EndsWith(".csv")) { Stream stream = file.InputStream; bool success = false; using (StreamReader reader = new StreamReader(stream, System.Text.Encoding.GetEncoding(1252))) { int lineCount = 0; string line = string.Empty; while ((line = reader.ReadLine()) != null) { //trenne bei ; wenn nicht innerhalb von Hochkommata string pattern = ";(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"; string[] lineArr = Regex.Split(line, pattern, RegexOptions.None, TimeSpan.FromSeconds(1)); // Spaltenanzahl zu gering if (lineArr.Length < 5) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "Die Datei muss mindestens 5 Spalten enthalten. Dies ist" + "nicht der Fall für Zeile " + lineCount + ".")); } // Header verarbeiten if (lineCount == 0) { LieferantenFile lieferantenFile = new LieferantenFile() { LieferantenFileName = file.FileName, LieferantenNummerColumnNameFromCSVImport = lineArr[0], LieferantenNameColumnNameFromCSVImport = lineArr[1], LieferantenStraßeColumnNameFromCSVImport = lineArr[2], LieferantenPLZColumnNameFromCSVImport = lineArr[3], LieferantenOrtColumnNameFromCSVImport = lineArr[4], LieferantenUpdatedAt = DateTime.Now }; using (ApplicationDbContext context = new ApplicationDbContext()) { success = context.UpdateLieferantenDateiForUser(userId, lieferantenFile); if (!success) { Log.Error("UpdateLieferantenDateiForUser nicht erfolgreich für Nutzer " + userId); return(new HttpStatusCodeResult(System.Net.HttpStatusCode.InternalServerError, "Fehler beim Schreiben in die DB. Bitte prüfen Sie die Log-Datei")); } } } // Lieferanten verarbeiten else { Lieferant lieferant = new Lieferant() { //TODO remove leading and trailing "" UserId = userId, Lieferantennummer = int.Parse(lineArr[0]), Lieferantenname = lineArr[1], Straße = lineArr[2], PLZ = int.Parse(lineArr[3]), Ort = lineArr[4], }; using (ApplicationDbContext context = new ApplicationDbContext()) { context.UpdateLieferant(lieferant); } } lineCount++; } } } else { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "Das Dateiformat wird nicht unterstützt.")); } } else { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "Bitte wählen Sie eine Datei aus.")); } } } catch (Exception e) { Log.Error(e.Message); return(new HttpStatusCodeResult(System.Net.HttpStatusCode.InternalServerError, "Bei der Verarbeitung der Import-Datei ist ein Fehler aufgetreten.")); } return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK)); }
public ActionResult UploadPalette(int?palettenId) { try { if (ModelState.IsValid) { int userId = ((CustomPrincipal)(User)).UserId; if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0) { HttpPostedFileBase file = Request.Files[0]; string fileName = file.FileName; if (fileName.EndsWith(".csv")) { // gibt es den Lieferanten überhaupt? string lieferantenNummer = fileName.Remove(fileName.Length - 4); Lieferant lieferant = null; using (ApplicationDbContext context = new ApplicationDbContext()) { lieferant = context.GetLieferantByLieferantennummer(int.Parse(lieferantenNummer)); if (lieferant == null) { return(new HttpNotFoundResult("Lieferant mit Nummer " + lieferantenNummer + " nicht gefunden. Hochladen der Artikeldatei nicht möglich.")); } } Stream stream = file.InputStream; using (StreamReader reader = new StreamReader(stream, System.Text.Encoding.GetEncoding(1252))) { int lineCount = 0; string line = string.Empty; while ((line = reader.ReadLine()) != null) { //trenne bei ; wenn nicht innerhalb von Hochkommata string pattern = ";(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"; string[] lineArr = Regex.Split(line, pattern, RegexOptions.None, TimeSpan.FromSeconds(1)); // Spaltenanzahl zu gering if (lineArr.Length < 2) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "Die Datei muss mindestens 2 Spalten enthalten. Dies ist" + "nicht der Fall für Zeile " + lineCount + ".")); } // Header verarbeiten if (lineCount == 0) { ArtikelFile artikelFile = new ArtikelFile() { ArtikelFileName = file.FileName, ArtikelnummerColumnNameFromCSVImport = lineArr[0], ArtikelnameColumnNameFromCSVImport = lineArr[1], PaletteUpdatedAt = DateTime.Now }; using (ApplicationDbContext context = new ApplicationDbContext()) { palettenId = context.UpdatePalette(lieferant.LieferantId, palettenId.HasValue ? palettenId.Value : -1, artikelFile); if (palettenId < 0) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.InternalServerError, "Fehler beim Schreiben in die DB. Bitte prüfen Sie die Log-Datei")); } } } // Artikel verarbeiten else { Artikel artikel = new Artikel() { //TODO remove leading and trailing "" PaletteId = palettenId.Value, Artikelnummer = lineArr[0], Artikelname = lineArr[1] }; using (ApplicationDbContext context = new ApplicationDbContext()) { context.UpdateArtikel(artikel); } } lineCount++; } } } else { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "Das Dateiformat wird nicht unterstützt.")); } } else { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "Bitte wählen Sie eine Datei aus.")); } } } catch (Exception e) { Log.Error(e.Message); return(new HttpStatusCodeResult(System.Net.HttpStatusCode.InternalServerError, "Bei der Verarbeitung der Import-Datei ist ein Fehler aufgetreten.")); } return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK)); }
void mbtnSetAutoProperties_Click(object sender, EventArgs e) { Kunde customer = null; Lieferant supplier = null; Kundenkontakt contact = null; Kundenmaschine machine = null; var msg = string.Empty; var msgBoxTitle = "Ausfüllen der Termineigenschaften" + Environment.NewLine; var subject = string.Empty; var location = string.Empty; var body = string.Empty; foreach (var lItem in ModelManager.AppointmentService.GetLinkedItemsList(this.myAppointment)) { if (lItem is Kunde) { customer = lItem as Kunde; } else if (lItem is Kundenkontakt) { contact = lItem as Kundenkontakt; } else if (lItem is Kundenmaschine) { machine = lItem as Kundenmaschine; } else if (lItem is Lieferant) { supplier = lItem as Lieferant; } } if (customer == null && supplier == null) { msg = "Bitte vorher den Termin zumindest mit einem Kunden oder einem Lieferanten verknüpfen."; MetroMessageBox.Show(this, msg, msgBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } msg = "Ich trage die Eigenschaften dieses Termins automatisch ein."; if (MetroMessageBox.Show(this, msg, msgBoxTitle, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.OK) { return; } switch (this.myAppointment.AppointmentType) { case "Kundenbesuch": if (customer != null) { subject = string.Format("{0}: Besuchstermin", customer.Matchcode); location = string.Format("{0}, {1} {2}", customer.Street, customer.ZipCode, customer.City); if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } } break; case "Schulung": if (supplier != null) { subject = string.Format("{0}: Schulung", supplier.Matchcode); location = string.Format("{0}, {1} {2}", supplier.Strasse, supplier.Postleitzahl, supplier.Ort); } break; case "Wartungstermin": if (machine != null) { subject = string.Format("{0}: Wartung {1} ({2})", customer.Matchcode, machine.Modellbezeichnung, machine.Seriennummer); } else { subject = string.Format("{0}: Wartung ", customer.Matchcode); } if (myCurrentUser.CalendarSettings.AddCustomerAddress) { location = string.Format("{0}, {1} {2}", customer.Street, customer.ZipCode, customer.City); } if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; case "Servicetermin": if (machine != null) { subject = string.Format("{0}: Service {1} ({2})", customer.Matchcode, machine.Modellbezeichnung, machine.Seriennummer); } else { subject = string.Format("{0}: Wartung ", customer.Matchcode); } if (myCurrentUser.CalendarSettings.AddCustomerAddress) { location = string.Format("{0}, {1} {2}", customer.Street, customer.ZipCode, customer.City); } if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; case "Fernwartung": subject = string.Format("{0}: Fernwartung", customer.Matchcode); location = "Technik CPM"; if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } break; case "Maschinenlieferung": if (machine != null) { subject = string.Format("{0}: Auslieferung {1} ({2})", customer.Matchcode, machine.Modellbezeichnung, machine.Seriennummer); } else { subject = string.Format("{0}: Auslieferung ", customer.Matchcode); } if (myCurrentUser.CalendarSettings.AddCustomerAddress) { location = string.Format("{0}, {1} {2}", customer.Street, customer.ZipCode, customer.City); } if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; case "Maschinenabholung": if (machine != null) { subject = string.Format("{0}: Abholung {1} ({2})", customer.Matchcode, machine.Modellbezeichnung, machine.Seriennummer); } else { subject = string.Format("{0}: Auslieferung ", customer.Matchcode); } location = "Technik CPM"; if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; case "Telefonat": subject = string.Format("{0}: Telefonat", customer.Matchcode); location = "Technik CPM"; if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; case "Undefiniert": subject = string.Format("{0}: Undefinierter Termin", customer.Matchcode); if (myCurrentUser.CalendarSettings.AddCustomerAddress) { location = string.Format("{0}, {1} {2}", customer.Street, customer.ZipCode, customer.City); } if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; case "Demo": if (machine != null) { subject = string.Format("{0}: Abholung {1} ({2})", customer.Matchcode, machine.Modellbezeichnung, machine.Seriennummer); } else { subject = string.Format("{0}: Demo ", customer.Matchcode); } if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; case "Besprechung": subject = "Besprechung"; location = "Empfang CPM"; body = string.Format(@"<p><strong><u>Teilnehmer</u></strong></p><ul>{0}</ul>", myCurrentUser.CalendarSettings.TargetUser.NameFull); break; default: subject = string.Format("{0}: {1}", customer.Matchcode, myAppointment.AppointmentType); if (myCurrentUser.CalendarSettings.AddCustomerAddress) { location = string.Format("{0}, {1} {2}", customer.Street, customer.ZipCode, customer.City); } if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; } this.myAppointment.Subject = subject; this.myAppointment.Location = location; this.myAppointment.BodyHtml = body; this.RefreshDataBindings(); }