public async Task <bool> Add(User user, Repeating repeating)
 {
     try
     {
         repeating.fk_UserId = user.Id;
         return(_repeatingRepository.Add(repeating));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        public bool Delete(Repeating repeating)
        {
            try
            {
                _context.FinanceRepeatings.Update(repeating);
                _context.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public async Task <bool> Update(User user, Repeating repeating)
        {
            try
            {
                var realRepeating = await GetById(user, repeating.Id);

                if (realRepeating != null)
                {
                    repeating.fk_UserId = user.Id;
                    return(_repeatingRepository.Update(repeating));
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public async Task <bool> Delete(User user, Repeating repeating)
        {
            try
            {
                var realRepeating = await GetById(user, repeating.Id);

                if (realRepeating != null)
                {
                    repeating.fk_UserId = user.Id;
                    repeating.Deleted   = true;
                    repeating.DeletedOn = DateTime.Today;
                    return(_repeatingRepository.Delete(repeating));
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #5
0
 /// <summary>
 /// Called when the instruction repeats.
 /// </summary>
 protected virtual void OnRepeating() =>
 Repeating?.Invoke(this, EventArgs.Empty);
Exemple #6
0
        public static IDictionary <string, List <IModifier> > ReadTriggerLex(string filename)
        {
            var lex = new Dictionary <string, List <IModifier> >();

            using (var reader = new StreamReader(filename))
                using (var csv = new CsvReader(reader))
                {
                    csv.Configuration.HasHeaderRecord = true;
                    //Triggerword	ModifierType	Lookahead	ModValue	Extra
                    csv.Read();
                    csv.Configuration.Delimiter = ",";
                    while (csv.Read())
                    {
                        var mods      = new List <IModifier>();
                        var tword     = Program.InternConcurrentSafe(csv.GetField(0).ToLower());
                        var lookahead = int.Parse(csv.GetField(2));
                        var modValue  = float.Parse(csv.GetField(3).Replace(".", ","));

                        IModifier modifier = null; // this could be waaaay prettier... Just wanted to try a switch case
                        switch (csv.GetField(1))
                        {
                        case "mult":
                            modifier = new Mult(modValue, lookahead);
                            break;

                        case "v":
                            var tokens = new List <Token>();
                            foreach (string s in csv.GetField(4).Split("|")) // couldn't a vending just take strings instead?... no reason to have a token
                            {
                                tokens.Add(new Token(s, 0));
                            }
                            modifier = new Vending(modValue, lookahead, tokens);
                            break;

                        case "neg":
                            modifier = new Mult(-1.0f, lookahead);
                            break;

                        case "repeating":
                            modifier = new Repeating(modValue, lookahead, tword, int.Parse(csv.GetField(4)));
                            break;

                        case "special":
                            modifier = new Special(modValue, lookahead);
                            break;

                        default:
                            FileWriter.WriteErrorLog("[TriggerLexicon] Couldn't match triggerword '" + tword + " -> is it unique in the lex?");
                            break;
                        }

                        if (!lex.ContainsKey(tword))
                        {
                            mods.Add(modifier);
                            if (!lex.TryAdd(tword, mods))
                            {
                                FileWriter.WriteErrorLog("[Lexicon] Couldn't add '" + tword + "' with mod " + modifier + " -> is it unique in the lex?");
                            }
                        }
                        else
                        {
                            lex.TryGetValue(tword, out mods);
                            mods.Add(modifier);
                            lex.Remove(tword);
                            lex.Add(tword, mods);
                        }
                    }
                    reader.Close();
                }
            return(lex);
        }