// PUT: api/Ressource/5 public void Put(ressClient majRes) { Ressource ressource = db.Ressource.Where(res => res.ID == majRes.id).FirstOrDefault(); ressource.Initial = majRes.initial; ressource.Name = majRes.name; ressource.Niveau = majRes.niveau; ressource.Mail = majRes.mail; ressource.Obsolete = false; List <Tarification_Ressource> tarRess = db.Tarification_Ressource.Where(t => t.FK_Ressource == majRes.id).ToList(); foreach (Tarification_Ressource tar in tarRess) { db.Tarification_Ressource.Attach(tar); db.Tarification_Ressource.Remove(tar); } db.SaveChanges(); foreach (Int16 idTar in majRes.tarification) { Tarification_Ressource tarification_ressource = new Tarification_Ressource(); tarification_ressource.FK_Ressource = majRes.id; Tarification tar = db.Tarification.Where(res => res.ID == idTar).FirstOrDefault(); tarification_ressource.FK_Tarification = tar.ID; db.Tarification_Ressource.Add(tarification_ressource); } db.SaveChanges(); }
public void updateValue() { Tarification tar = this.db.Tarification.Where(x => x.Type == "Directeur technique").FirstOrDefault(); decimal dailyValue = Convert.ToDecimal((this.jrs != null ? this.jrs : 0) * tar.Tar5); decimal dailyValueWE = Convert.ToDecimal((this.we != null ? this.we : 0) * tar.Tar5 * 1.5m); decimal dailyValueF = Convert.ToDecimal((this.f != null ? this.f : 0) * tar.Tar5 * 2m); this.sum = Convert.ToDecimal(dailyValue + dailyValueWE + dailyValueF); }
public void updateValue() { Tarification tar = db.Tarification.Where(x => x.Type == "Chef de projet fonctionnel").FirstOrDefault(); decimal dailyValue = Convert.ToDecimal((this.jours != null ? this.jours : 0) * tar.Tar5); decimal dailyValueWE = Convert.ToDecimal((this.weekend != null ? this.weekend : 0) * tar.Tar5 * 1.5m); decimal dailyValueF = Convert.ToDecimal((this.férié != null ? this.férié : 0) * tar.Tar5 * 2m); this.sum = Convert.ToDecimal(dailyValue + dailyValueWE + dailyValueF); }
// PUT: api/Tarification/5 public void Put(tarifiClient majT) // met a jour une Tarification a partir de son ID { Tarification tarif = db.Tarification.Where(t => t.ID == majT.id).FirstOrDefault(); tarif.IsAmo = majT.isAmo; tarif.Tar3 = majT.tar3; tarif.Tar5 = majT.tar5; tarif.Type = majT.type; db.SaveChanges(); }
// POST: api/Tarification public void Post(tarifiClient tarifclient) // creer et ajoute à la bd une nouvelle Tarification { Tarification nouveauTarif = new Tarification(); nouveauTarif.Type = tarifclient.type; nouveauTarif.Tar3 = tarifclient.tar3; nouveauTarif.Tar5 = tarifclient.tar5; nouveauTarif.IsAmo = tarifclient.isAmo; nouveauTarif.Date = DateTime.Now; nouveauTarif.Obsolete = false; db.Tarification.Add(nouveauTarif); db.SaveChanges(); }
// GET: api/Tarification/5 public Tarification Get(int id) // renvoi la tarification d'id ID { Tarification res = this.db.Tarification.Where(s => s.ID == id).FirstOrDefault(); // renvoi l'objet pointé par l'id pris en paramètre if (res != null) { return(res); } else { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, "pas d'objet pour cet ID")); } }
// DELETE: api/Tarification/5 public void Delete(int id) // Détruit un objet Tarification a partir de son ID { Tarification tar = db.Tarification.Where(t => t.ID == id).FirstOrDefault(); // récupération de la tache pointé par l'id List <Tarification_Ressource> tarRes = db.Tarification_Ressource.Where(t => t.FK_Tarification == id).ToList(); foreach (Tarification_Ressource tr in tarRes) { db.Tarification_Ressource.Attach(tr); db.Tarification_Ressource.Remove(tr); } db.Tarification.Attach(tar); // ecouter les changement de l'objet db.Tarification.Remove(tar); // remove l'objet ts db.SaveChanges(); // mettre a jour la table }
public void updateValue(bool isAmo) { using (DevisEntities cont = new DevisEntities()) { Ressource res = cont.Ressource.Where(x => x.Initial == initials).Include(x => x.Tarification_Ressource).FirstOrDefault(); if (res != null) { List <long> typeId = res.Tarification_Ressource.Select(x => x.FK_Tarification).ToList(); Tarification tar = cont.Tarification.Where(x => typeId.Contains(x.ID) && x.IsAmo == isAmo).FirstOrDefault(); decimal dailyValue = this.value != null?Math.Round(Convert.ToDecimal(this.value / 7), 2) : 0; dailyValue = getDecimalPart(dailyValue); this.value = Math.Round(dailyValue * (res.Niveau == 3 ? (decimal)tar.Tar3 : (decimal)tar.Tar5), 2); } } }
public Facturation(string initials, bool isAmo, long type) { using (DevisEntities cont = new DevisEntities()) { Ressource res = cont.Ressource.Where(x => x.Initial == initials).FirstOrDefault(); if (res != null) { List <long> typeId = res.Tarification_Ressource.Select(x => x.FK_Tarification).ToList(); Tarification tar = cont.Tarification.Where(x => typeId.Contains(x.ID) && x.IsAmo == isAmo).FirstOrDefault(); if (tar != null) { this.initials = res.Initial; decimal dailyValue = this.value != null?Math.Round(Convert.ToDecimal(this.value / 7), 2) : 0; this.value = Math.Round(dailyValue * (res.Niveau == 3 ? (decimal)tar.Tar3 : (decimal)tar.Tar5), 2); } } } }
// POST: api/Ressource public void Post(ressClient rss) // Ajout d'une nouvelle ressource { Ressource newRess = new Ressource(); newRess.Initial = rss.initial; newRess.Mail = rss.mail; newRess.Name = rss.name; newRess.Niveau = rss.niveau; newRess.Obsolete = false; newRess.Date = DateTime.Now; Tarification_Ressource tarRes = new Tarification_Ressource(); foreach (Int16 idTar in rss.tarification) { tarRes.FK_Ressource = newRess.ID; Tarification tar = db.Tarification.Where(res => res.ID == idTar).FirstOrDefault(); tarRes.FK_Tarification = tar.ID; } db.Ressource.Add(newRess); db.Tarification_Ressource.Add(tarRes); db.SaveChanges(); }
protected override void ConfigureWebHost(IWebHostBuilder builder) { builder.ConfigureServices(services => { var descriptor = services.SingleOrDefault( d => d.ServiceType == typeof(DbContextOptions <GestecoContext>)); services.Remove(descriptor); services.AddDbContext <GestecoContext>(options => { options.UseInMemoryDatabase("InMemoryDbForTesting_"); options.ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning)); }); var sp = services.BuildServiceProvider(); using (var scope = sp.CreateScope()) { var scopedServices = scope.ServiceProvider; var db = scopedServices.GetRequiredService <GestecoContext>(); var logger = scopedServices .GetRequiredService <ILogger <CustomWebApplicationFactory <TStartup> > >(); db.Database.EnsureCreated(); try { if (!db.Quota_Standard.Any()) { var quota_Standard = new Quota_Standard { Quantite = 20, Quantite_Commerce = 20 }; db.Quota_Standard.Add(quota_Standard); db.SaveChanges(); } /// verifit s"il deja des donnee dans la table tarification if (!db.Tarification.Any()) { var tarification = new Tarification { Prix = 11, Prix_Commerce = 32 }; db.Tarification.Add(tarification); db.SaveChanges(); } /// verifit s"il deja des donnee dans la table ModePaiement if (!db.ModePaiement.Any()) { var modepaiement = new List <ModePaiement> { new ModePaiement { Nom = "Comptant" }, new ModePaiement { Nom = "Debit" }, new ModePaiement { Nom = "Credit" }, new ModePaiement { Nom = "Autres" }, }; db.ModePaiement.AddRange(modepaiement); db.SaveChanges(); } /// verifit s"il deja des donnee dans la table ModePaiement if (!db.Historique_Initialisation_Quota.Any()) { var quotaInit = new Historique_Initialisation_Quota { DateEncours = true, DateInit = DateTime.Now, Description = "Initialisation de depart" }; db.Historique_Initialisation_Quota.Add(quotaInit); db.SaveChanges(); } } catch (Exception ex) { logger.LogError(ex, "An error occurred seeding the " + "database with test messages. Error: {Message}", ex.Message); } } }); }
public void updateValue(bool isAmo) { Ressource res = db.Ressource.Include("Tarification_Ressource").Where(x => x.Initial == initials).FirstOrDefault(); // Recuperation de la personne correspondant aux initials Tarification tar = new Tarification(); // creation d'un nouvel objet Tarification if (res != null) // Si l'objet n'est pas null { List <long> typeId = res.Tarification_Ressource.Select(x => x.FK_Tarification).ToList(); // Récupération des id's correspondant à la personne pointé par les initals if (!res.isFullAMO()) // si la personne n'est pas Full Amo { tar = db.Tarification.Where(x => typeId.Contains(x.ID) && x.IsAmo == isAmo).FirstOrDefault(); // je récupère la tarification de la personne correspondant au bool Amo pris en param } //SI la personne n'as que des tarifs amo else { if (isAmo) { //Si la tache est typé amo alors on prend la valeur tarifaire la plus cher List <Tarification> lesTarifications = db.Tarification.Where(x => typeId.Contains(x.ID)).ToList(); // récuperation des differentes tarification correspondant a l'id de la personne if (lesTarifications.Count > 1) // si il y en a plus d'une { if (res.Niveau == 3) // si le niveau de cette personne est bac+3 { tar = lesTarifications.Select(s => s).OrderByDescending(s => s.Tar3).FirstOrDefault(); // je prend la tarification la plus chère correspondant au niveau bac+ 3 } else { tar = lesTarifications.Select(s => s).OrderByDescending(s => s.Tar5).FirstOrDefault(); // je prend la tarification la plus chère correspondant au niveau bac+ 5 } } else { tar = lesTarifications.FirstOrDefault(); } } else // Sinon si la tache n'est pas typé amo { List <Tarification> tars = db.Tarification.Where(x => typeId.Contains(x.ID)).ToList(); // je recupère les tartification correspondant à la personne if (tars.Count > 1) // si il y a plus d'ue tarification { if (res.Niveau == 3) // si niveaux personne => b + 3 { tar = tars.Select(s => s).OrderBy(s => s.Tar3).FirstOrDefault(); // première tarification ordonnée a partir de tarification de niveaux 3 } else // sinon si niveaux personne => b + 5 { tar = tars.Select(s => s).OrderBy(s => s.Tar5).FirstOrDefault(); // première tarification ordonnée a partir de tarification de niveaux 5 } } else // sinon { tar = tars.FirstOrDefault(); // je prend la seul qui est dispo } } } decimal dailyValue = this.value != null?Math.Round(Convert.ToDecimal(this.value / 7), 2) : 0; // conversion en jour decimal dailyValueWE = this.valueWE != null?Math.Round(Convert.ToDecimal(this.valueWE / 7), 2) : 0; // conversion en jour decimal dailyValueF = this.valueF != null?Math.Round(Convert.ToDecimal(this.valueF / 7), 2) : 0; // conversion en jour dailyValue = getDecimalPart(dailyValue); //Arrondie au supérieur dailyValueWE = getDecimalPart(dailyValueWE); //Arrondie au supérieur dailyValueF = getDecimalPart(dailyValueF); //Arrondie au supérieur this.value = Math.Round(dailyValue * (res.Niveau == 3 ? (decimal)tar.Tar3 : (decimal)tar.Tar5), 2); // je prend la valeur en fonction de son niveau if (this.valueWE != null) { this.valueWE = Math.Round(dailyValueWE * (res.Niveau == 3 ? (decimal)tar.Tar3 : (decimal)tar.Tar5), 2) * 1.5m; // si la personne a travailler le weekend j'applique le tarif weekend } else { this.valueWE = 0; // Tarif weekend = 0 } if (this.valueF != null) { this.valueF = Math.Round(dailyValueF * (res.Niveau == 3 ? (decimal)tar.Tar3 : (decimal)tar.Tar5), 2) * 2m; // si la personne a travailler un jour férié j'applique le tarif férié } else { this.valueF = 0; // Tarif férié = 0 } this.sum = Convert.ToDecimal(this.value + this.valueWE + this.valueF); //j'applique la somme de tout les tarifs pour la personne } }
public static void Seed(GestecoContext context) { /// verifit s"il deja des donnee dans la table quota standard if (!context.Quota_Standard.Any()) { var quota_Standard = new Quota_Standard { Quantite = 20, Quantite_Commerce = 20 }; context.Quota_Standard.Add(quota_Standard); context.SaveChanges(); } /// verifit s"il deja des donnee dans la table tarification if (!context.Tarification.Any()) { var tarification = new Tarification { Prix = 11, Prix_Commerce = 32 }; context.Tarification.Add(tarification); context.SaveChanges(); } /// verifit s"il deja des donnee dans la table ModePaiement if (!context.ModePaiement.Any()) { var modepaiement = new List <ModePaiement> { new ModePaiement { Nom = "Comptant" }, new ModePaiement { Nom = "Debit" }, new ModePaiement { Nom = "Credit" }, new ModePaiement { Nom = "Autres" }, }; context.ModePaiement.AddRange(modepaiement); context.SaveChanges(); } /// verifit s"il deja des donnee dans la table ModePaiement if (!context.Historique_Initialisation_Quota.Any()) { var quotaInit = new Historique_Initialisation_Quota { DateEncours = true, DateInit = DateTime.Now, Description = "Initialisation de depart" }; context.Historique_Initialisation_Quota.Add(quotaInit); context.SaveChanges(); } }