public async Task <ActionResult <ManualCashFlow> > PostManualCashFlow(tempManualCashFlow mcf)
        {
            CFType           type           = _context.CFTypes.Find(mcf.CFType);
            CFClassification classification = _context.CFClassifications.Find(mcf.CFClassification);
            ManualCashFlow   cf             = new ManualCashFlow(type, classification, mcf.Amount, mcf.DateBooked, mcf.SourceOfExpense, mcf.UserId, mcf.Expected, mcf.ExpenseLocation);

            if (ModelState.IsValid)
            {
                _context.ManualCashFlows.Add(cf);
            }
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException ex)
            {
                if (ManualCashFlowExists(cf.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetManualCashFlow", new { id = cf.Id }, cf));
        }
Esempio n. 2
0
        public ActionResult GetClassification()
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("GetClassification", true, false, "", auth.Identity.Name);
                CFClassification cf = new CFClassification();
                return(Ok(cf.GetList()));
            }
            return(Ok(""));
        }
Esempio n. 3
0
        public static void Initialize(FinPlannerContext context)
        {
            context.Database.EnsureCreated();
            if (context.CFTypes.Any())
            {
                return;
            }
            var cfTypes = new CFType[]
            {
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Salary"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Rent"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Groceries"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Electricty"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Loans"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Car Loan"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Insurance"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Bank Charges"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Domestic"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Cellphone"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Gym"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Internet"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Medical Aid"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Entertainment"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Takeout"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "School Fees"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Transportation"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = false, Name = "Medication"
                },
                new CFType {
                    Id = Guid.NewGuid().ToString(), Custom = true, ClientReference = "999", Name = "Transfer"
                }
            };

            foreach (CFType item in cfTypes)
            {
                context.CFTypes.Add(item);
            }
            context.SaveChanges();
            if (context.CFClassifications.Any())
            {
                return;
            }
            var cfClass = new CFClassification[]
            {
                new CFClassification {
                    Id = Guid.NewGuid().ToString(), Name = "Income", Sign = 1
                },
                new CFClassification {
                    Id = Guid.NewGuid().ToString(), Name = "Expense", Sign = -1
                },
            };

            foreach (CFClassification item in cfClass)
            {
                context.CFClassifications.Add(item);
            }
            context.SaveChanges();
        }