public async Task <IActionResult> PutBudgetDescription([FromRoute] int id, [FromBody] BudgetDescription budgetDescription)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != budgetDescription.BudgetDescriptionId)
            {
                return(BadRequest());
            }

            _context.Entry(budgetDescription).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BudgetDescriptionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(budgetDescription));
        }
        public async Task <IActionResult> PostBudgetDescription([FromBody] BudgetDescription budgetDescription)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.BudgetDescription.Add(budgetDescription);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBudgetDescription", new { id = budgetDescription.BudgetDescriptionId }, budgetDescription));
        }
Exemplo n.º 3
0
 public void WriteCustomTemplate(BudgetDescription templateData)
 {
     try
     {
         var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
         var filePath      = Path.Combine(documentsPath, BudgetTemplateFilename);
         var jsonString    = JsonConvert.SerializeObject(templateData);
         File.WriteAllText(filePath, jsonString);
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 4
0
        public Task <BudgetDescription> ReadCustomTemplate()
        {
            return(Task.Factory.StartNew(() =>
            {
                BudgetDescription data = null;
                var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                var filePath = Path.Combine(documentsPath, BudgetTemplateFilename);
                if (File.Exists(filePath))
                {
                    var jsonString = File.ReadAllText(filePath);
                    data = JsonConvert.DeserializeObject <BudgetDescription>(jsonString);
                }

                return data;
            }));
        }
Exemplo n.º 5
0
 public async Task UploadBudgetTemplate(BudgetDescription data)
 {
     await _cloudStorage.UploadBudgetTemplate(data);
 }