public async Task Put([FromBody] Cyclus obj)
 {
     try
     {
         await EigenschapService.Update(obj);
     }
     catch (Exception ex)
     {
     }
 }
 // DELETE
 public void Delete(Cyclus obj)
 {
     try
     {
         DB.Cyclus.Remove(obj);
     }
     catch (Exception)
     {
         throw;
     }
 }
 // UPDATE
 public void Update(Cyclus obj)
 {
     try
     {
         DB.Cyclus.Update(obj);
     }
     catch (Exception)
     {
         throw;
     }
 }
 // CREATE
 public void Create(Cyclus obj)
 {
     try
     {
         DB.Cyclus.Add(obj);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 5
0
 // CREATE
 public async Task Create(Cyclus obj)
 {
     try
     {
         repository.Create(obj);
         await DB.SaveChangesAsync();
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 6
0
    //if statement to show the questionscene once a week
    public void Knop(bool antwoord)
    {
        if (antwoord)
        {
            Cyclus cyclusmanager = new Cyclus();
            cyclusmanager.ChangeCyclus();
        }

        LaatsteDatum laatstedatum = new LaatsteDatum();

        laatstedatum.WriteFirstDate(DateTime.Now);
        RandomScene.loadRandomScene();
    }
Ejemplo n.º 7
0
        /// <summary>
        /// Write AppOpenDate to a local json file
        /// </summary>
        public void writeToJSON()
        {
            string path = Application.persistentDataPath + "/AppOpenDate.json";

            //Check if json file is empty or not.

            if (File.Exists(path))
            {
                List <AppOpenDate> appOpenDateList;
                using (StreamReader r = new StreamReader(path))
                {
                    string json = r.ReadToEnd();
                    appOpenDateList = JsonConvert.DeserializeObject <List <AppOpenDate> >(json, Constants.jsonSerializerSettings);
                    foreach (AppOpenDate item in appOpenDateList)
                    {
                        //set to localtime since datetime from json are UTC
                        item.datetimeOpened = item.datetimeOpened.ToLocalTime();
                    }
                    r.Close();
                }

                DateTime endOfCyclusCalculationPeriod = appOpenDateList.First().datetimeOpened.AddDays(CALCULATION_DURATION_DAYS);

                LaatsteDatum laatstedatum = new LaatsteDatum();
                laatstedatum.CreateFirstDate(endOfCyclusCalculationPeriod);

                DateTime lastOpened = appOpenDateList.Last().datetimeOpened.AddMinutes(MINUTES_BETWEEN_SMOKES);

                //DateTime is before end of cyclus calculation period and atleast 1 hour after the last datetime added.
                if (datetimeOpened < endOfCyclusCalculationPeriod && lastOpened < datetimeOpened)
                {
                    appOpenDateList.Add(this);
                    File.WriteAllText(path, JsonConvert.SerializeObject(appOpenDateList, Constants.jsonSerializerSettings));
                }
                else if (datetimeOpened >= endOfCyclusCalculationPeriod)
                {
                    Cyclus cyclus = new Cyclus();
                    cyclus.createCyclus(appOpenDateList);
                }
            }
            else
            {
                //Json file doesn't exist so create file and write down the first datetime
                File.Create(path).Close();
                File.WriteAllText(path, "[" + JsonConvert.SerializeObject(this, Constants.jsonSerializerSettings) + "]");
            }
        }
Ejemplo n.º 8
0
        public async Task Clone(Cyclus obj)
        // Dupliceren van Cylus
        {
            try
            {
                // Ophalen van object
                Cyclus completeCylus = await this.GetFromID(obj.Id);

                Cyclus newCyclus = new Cyclus();
                newCyclus.Id = 0;
                newCyclus.MachineOnderdeelId = obj.MachineOnderdeelId;
                newCyclus.Naam = obj.Naam + "(COPY)";

                newCyclus.CyclusTypeId = obj.CyclusTypeId;
                newCyclus.CyclusType   = null;

                foreach (CyclusMaakInstelling item in completeCylus.CyclusMaakInstelling)
                {
                    CyclusMaakInstelling cmi = new CyclusMaakInstelling();
                    cmi.Id               = 0;
                    cmi.CyclusId         = 0;
                    cmi.MaakInstellingId = item.MaakInstellingId;
                    cmi.Stap             = item.Stap;
                    cmi.ChildStap        = item.ChildStap;

                    cmi.ProductEigenschapId = item.ProductEigenschapId;
                    cmi.ProductEigenschap   = null;

                    cmi.StaticWaarde = item.StaticWaarde;
                    cmi.Check        = item.Check;

                    // Voeg nieuwe maak instelling toe
                    newCyclus.CyclusMaakInstelling.Add(cmi);
                }

                // Save To DB
                await this.Create(newCyclus);
            }
            catch (Exception ex)
            {
                throw;
            }
        }