예제 #1
0
        public IHttpActionResult PutIncomeDetail(int id, IncomeDetail incomeDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != incomeDetail.ID)
            {
                return(BadRequest());
            }

            db.Entry(incomeDetail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!IncomeDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            IncomeDetail incomeDetail = db.IncomeDetails.Find(id);

            db.IncomeDetails.Remove(incomeDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public JsonResult InsertIncome(IncomeDetail incomeDetail)
        {
            using (ApplicationDbContext entities = new ApplicationDbContext())
            {
                entities.IncomeDetails.Add(incomeDetail);
                entities.SaveChanges();
            }

            return(Json(incomeDetail));
        }
예제 #4
0
 public ActionResult Edit(IncomeDetail incomeDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(incomeDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Edit", "MonthlyPlanner", new { planId = incomeDetail.planId }));
     }
     return(RedirectToAction("ListIndex", "MonthlyPlanner"));
 }
예제 #5
0
        public IHttpActionResult GetIncomeDetail(int id)
        {
            IncomeDetail incomeDetail = db.IncomeDetails.Find(id);

            if (incomeDetail == null)
            {
                return(NotFound());
            }

            return(Ok(incomeDetail));
        }
예제 #6
0
        public ActionResult Create([Bind(Include = "IncomeId,ActualAmount,SubCategoryId,CreditDate,ForMonth,FinancialYear")] IncomeDetail incomeDetail)
        {
            if (ModelState.IsValid)
            {
                db.IncomeDetails.Add(incomeDetail);
                db.SaveChanges();
                return(RedirectToAction("Index", "MonthlyPlanner"));
            }

            return(View("Index", "MonthlyPlanner"));
        }
예제 #7
0
 public ActionResult DeleteCustomer(int incomeId)
 {
     using (ApplicationDbContext entities = new ApplicationDbContext())
     {
         IncomeDetail incomeDetail = (from c in entities.IncomeDetails
                                      where c.IncomeId == incomeId
                                      select c).FirstOrDefault();
         entities.IncomeDetails.Remove(incomeDetail);
         entities.SaveChanges();
     }
     return(new EmptyResult());
 }
예제 #8
0
        public async Task <IActionResult> Crear([FromBody] CreateEntryDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var fechaHora = DateTime.Now;

            Entry ingreso = new Entry
            {
                idproveedor       = model.idproveedor,
                idusuario         = model.idusuario,
                tipo_comprobante  = model.tipo_comprobante,
                serie_comprobante = model.serie_comprobante,
                num_comprobante   = model.num_comprobante,
                fecha_hora        = fechaHora,
                impuesto          = model.impuesto,
                total             = model.total,
                estado            = "Aceptado"
            };


            try
            {
                _context.Entries.Add(ingreso);
                await _context.SaveChangesAsync();

                var id = ingreso.idingreso;
                foreach (var det in model.detalles)
                {
                    IncomeDetail detalle = new IncomeDetail
                    {
                        idingreso  = id,
                        idarticulo = det.idarticulo,
                        cantidad   = det.cantidad,
                        precio     = det.precio,
                        nombre     = det.nombre,
                        direccion  = det.direccion,
                        telefono   = det.telefono
                    };
                    _context.IncomeDetails.Add(detalle);
                }
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }

            return(Ok());
        }
예제 #9
0
        public override ActionResult Edit(IncomeViewModel viewModel)
        {
            Income entity     = AssignViewModelToEntity(viewModel);
            var    businessId = User.Identity.GetBusinessId();

            if (businessId != null)
            {
                entity.BusinessId = businessId.Value;
            }

            //delete existing income detail
            var incomeDetailService = new IncomeDetailService(UnitOfWork);

            incomeDetailService.Filter(o => o.IncomeId == viewModel.Id)
            .ForEach(o => incomeDetailService.Delete(o.Id));
            //incomeDetailService.Save();

            foreach (var incomeDetail in viewModel.IncomeDetails)
            {
                var detail = new IncomeDetail
                {
                    BusinessId      = (Guid)businessId,
                    IncomeId        = entity.Id,
                    IncomeAccountId = incomeDetail.IncomeAccountId,
                    Description     = incomeDetail.Description,
                    Quantity        = incomeDetail.Quantity,
                    Price           = incomeDetail.Price,
                    SalesTaxId      = incomeDetail.SalesTaxId
                };

                incomeDetailService.Insert(detail);
            }
            //incomeDetailService.Save();


            //var actionExceptionHelper = new ActionResultHelper<TEntity>(typeof(TViewModel));
            //actionExceptionHelper.Method += Update;
            Update(entity);
            //var result = Validate(entity, _CleanUpControllerName(), "Edit");
            //if (!result.Passed)
            //    _EditReturnPartialViewOnError(viewModel);

            //var actionResultMessage = actionExceptionHelper.Process(entity, ModelState, CrudTransactionResultConstant.Update);
            //var actionResultMessage = actionExceptionHelper.Process(entity, ModelState, _setting.GetMessage(SystemMessageConstant.RecordUpdated));

            //return Json(actionResultMessage, JsonRequestBehavior.AllowGet);
            //return actionResultMessage.ActionStatus == ActionStatusResult.Failed
            //   ? _EditReturnPartialViewOnError(viewModel)
            //   : Json(actionResultMessage, JsonRequestBehavior.AllowGet);
            return(RedirectToAction("Index"));
        }
예제 #10
0
        // GET: IncomeDetails/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IncomeDetail incomeDetail = db.IncomeDetails.Find(id);

            if (incomeDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(incomeDetail));
        }
예제 #11
0
        public IHttpActionResult DeleteIncomeDetail(int id)
        {
            IncomeDetail incomeDetail = db.IncomeDetails.Find(id);

            if (incomeDetail == null)
            {
                return(NotFound());
            }

            db.IncomeDetails.Remove(incomeDetail);
            db.SaveChanges();

            return(Ok(incomeDetail));
        }
예제 #12
0
        public IHttpActionResult PostIncomeDetail(IncomeDetail incomeDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var dateAndTime = DateTime.Now;

            incomeDetail.CreatedDate = dateAndTime.Date;

            db.IncomeDetails.Add(incomeDetail);
            db.SaveChanges();

            return(CreatedAtRoute("InsertExpenseDetails", new { id = incomeDetail.ID }, incomeDetail));
        }
예제 #13
0
        public ActionResult UpdateCustomer(IncomeDetail incomeDetail)
        {
            using (ApplicationDbContext entities = new ApplicationDbContext())
            {
                IncomeDetail updatedDetail = (from c in entities.IncomeDetails
                                              where c.IncomeId == incomeDetail.IncomeId
                                              select c).FirstOrDefault();
                updatedDetail.ActualAmount  = incomeDetail.ActualAmount;
                updatedDetail.CreditDate    = incomeDetail.CreditDate;
                updatedDetail.FinancialYear = incomeDetail.FinancialYear;
                updatedDetail.ForMonth      = incomeDetail.ForMonth;
                updatedDetail.SubCategoryId = incomeDetail.SubCategoryId;

                entities.SaveChanges();
            }

            return(new EmptyResult());
        }
예제 #14
0
        // GET: IncomeDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IncomeDetail incomeDetail = db.IncomeDetails.Find(id);
            var          items        = db.SubCategories.Where(x => x.ParentCategoryId == 1).ToList();

            if (items != null)
            {
                ViewBag.SubCategories = items;
            }
            if (incomeDetail == null)
            {
                return(HttpNotFound());
            }
            return(PartialView("_EditIncome", incomeDetail));
        }
예제 #15
0
        public override ActionResult Create(IncomeViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(SetViewModelData(viewModel)));
            }

            Income entity = AssignViewModelToEntity(viewModel);
            //var helper = new ActionResultHelper<TEntity>(typeof(TViewModel));
            //helper.Method += Add;
            var businessId = User.Identity.GetBusinessId();

            if (businessId != null)
            {
                entity.BusinessId = businessId.Value;
            }
            Add(entity);

            var incomeDetailService = new IncomeDetailService(UnitOfWork);

            foreach (var incomeDetail in viewModel.IncomeDetails)
            {
                var detail = new IncomeDetail
                {
                    BusinessId      = (Guid)businessId,
                    IncomeId        = entity.Id,
                    IncomeAccountId = incomeDetail.IncomeAccountId,
                    Description     = incomeDetail.Description,
                    Quantity        = incomeDetail.Quantity,
                    Price           = incomeDetail.Price,
                    SalesTaxId      = incomeDetail.SalesTaxId
                };

                incomeDetailService.Insert(detail);
            }

            incomeDetailService.Save();
            return(RedirectToAction("Index"));
        }
예제 #16
0
        public ActionResult Create(MonthlyPlannerViewModel model)
        {
            ViewBag.Years = new SelectList(Enumerable.Range(DateTime.Today.Year, 20).Select(x =>
                                                                                            new SelectListItem()
            {
                Text  = x.ToString() + "-" + (x + 1).ToString(),
                Value = x.ToString() + "-" + (x + 1).ToString()
            }), "Value", "Text");
            var plans = db.MonthlyPlans.ToList();

            if (plans.Any(x => x.ForMonth == model.ForMonth && x.FinancialYear == model.FinancialYear))
            {
                ViewBag.Message = "Plan for this month already exists.";
                return(View());
            }

            var items = db.SubCategories.Where(x => x.ParentCategoryId == 1).ToList();

            if (items != null)
            {
                ViewBag.SubCategories = items;
            }


            //generate default Income list
            var _defaultIncome = db.SubCategories.Where(x => x.ParentCategoryId == 1 && x.IsDefault == true).ToList();
            var _incomeList    = new List <IncomeDetail>();

            foreach (var item in _defaultIncome)
            {
                var _addIncome = new IncomeDetail();
                _addIncome.SubCategoryId   = item.SubCategoryId;
                _addIncome.ActualAmount    = 0;
                _addIncome.CreditDate      = DateTime.Now;
                _addIncome.FinancialYear   = model.FinancialYear;
                _addIncome.ForMonth        = model.ForMonth;
                _addIncome.SubCategoryName = item.Name;
                db.IncomeDetails.Add(_addIncome);
                _incomeList.Add(_addIncome);
            }
            model.IncomeDetails = _incomeList;

            //generate default expenses
            var _defaultExpenses = db.SubCategories.Where(x => x.ParentCategoryId == 2 && x.IsDefault == true).ToList();
            var _expenseList     = new List <ExpenseDetail>();

            foreach (var item in _defaultExpenses)
            {
                var _addExpense = new ExpenseDetail();
                _addExpense.SubCategoryId   = item.SubCategoryId;
                _addExpense.ActualAmount    = 0;
                _addExpense.DebitDate       = DateTime.Now;
                _addExpense.FinancialYear   = model.FinancialYear;
                _addExpense.ForMonth        = model.ForMonth;
                _addExpense.SubCategoryName = item.Name;
                db.ExpenseDetails.Add(_addExpense);
                _expenseList.Add(_addExpense);
            }
            model.ExpenseDetails = _expenseList;

            //default savings
            var _defaultSavings = db.SubCategories.Where(x => x.ParentCategoryId == 3 && x.IsDefault == true).ToList();
            var _savingsList    = new List <SavingsDetail>();

            foreach (var item in _defaultSavings)
            {
                var _addSavings = new SavingsDetail();
                _addSavings.SubCategoryId   = item.SubCategoryId;
                _addSavings.ActualAmount    = 0;
                _addSavings.Date            = DateTime.Now;
                _addSavings.FinancialYear   = model.FinancialYear;
                _addSavings.ForMonth        = model.ForMonth;
                _addSavings.SubCategoryName = item.Name;
                db.SavingsDetails.Add(_addSavings);
                _savingsList.Add(_addSavings);
            }
            model.SavingsDetails = _savingsList;

            //default Investment
            var _defaultInvestments = db.SubCategories.Where(x => x.ParentCategoryId == 4 && x.IsDefault == true).ToList();
            var _investList         = new List <InvestmentDetail>();

            foreach (var item in _defaultInvestments)
            {
                var _addInvestments = new InvestmentDetail();
                _addInvestments.SubCategoryId   = item.SubCategoryId;
                _addInvestments.ActualAmount    = 0;
                _addInvestments.DebitDate       = DateTime.Now;
                _addInvestments.FinancialYear   = model.FinancialYear;
                _addInvestments.ForMonth        = model.ForMonth;
                _addInvestments.SubCategoryName = item.Name;
                db.InvestmentDetails.Add(_addInvestments);
                _investList.Add(_addInvestments);
            }
            model.InvestmentDetails = _investList;

            db.SaveChanges();

            var newPlan = new MonthlyPlan();

            newPlan.ForMonth      = model.ForMonth;
            newPlan.FinancialYear = model.FinancialYear;
            newPlan.CreatedOn     = DateTime.Now;
            db.MonthlyPlans.Add(newPlan);
            db.SaveChanges();

            //generate view
            var categories = db.Categories.Join(db.SubCategories, x => x.CategoryId, y => y.ParentCategoryId,
                                                (x, y) => new { x, y }).Select(y => new MonthlyPlannerViewModel
            {
                CategoryId      = y.y.ParentCategoryId,
                CategoryName    = y.x.CategoryName,
                SubCategoryId   = y.y.SubCategoryId,
                ExpectedAmount  = y.y.ExpectedAmount,
                SubCategoryName = y.y.Name
            }).ToList();

            var _incomeData = model.IncomeDetails.Join(categories, x => x.SubCategoryId, y => y.SubCategoryId, (x, y) => new { x, y }).Select
                                  (y => new MonthlyPlannerViewModel
            {
                IncomeId        = y.x.IncomeId,
                CategoryId      = y.y.CategoryId,
                CategoryName    = y.y.CategoryName,
                SubCategoryId   = y.y.SubCategoryId,
                SubCategoryName = y.y.SubCategoryName,
                ActualAmount    = y.x.ActualAmount,
                CreditDate      = y.x.CreditDate,
                FinancialYear   = y.x.FinancialYear,
                ForMonth        = y.x.ForMonth,
                ExpectedAmount  = y.y.ExpectedAmount
            }).ToList();
            var _expenseData = model.ExpenseDetails.Join(categories, x => x.SubCategoryId, y => y.SubCategoryId, (x, y) => new { x, y }).Select
                                   (y => new MonthlyPlannerViewModel
            {
                ExpenseId       = y.x.ExpenseId,
                CategoryId      = y.y.CategoryId,
                CategoryName    = y.y.CategoryName,
                SubCategoryId   = y.y.SubCategoryId,
                SubCategoryName = y.y.SubCategoryName,
                ActualAmount    = y.x.ActualAmount,
                DebitDate       = y.x.DebitDate,
                FinancialYear   = y.x.FinancialYear,
                ForMonth        = y.x.ForMonth,
                ExpectedAmount  = y.y.ExpectedAmount
            }).ToList();
            var _savingsData = model.SavingsDetails.Join(categories, x => x.SubCategoryId, y => y.SubCategoryId, (x, y) => new { x, y }).Select
                                   (y => new MonthlyPlannerViewModel
            {
                SavingsId       = y.x.SavingsId,
                CategoryId      = y.y.CategoryId,
                CategoryName    = y.y.CategoryName,
                SubCategoryId   = y.y.SubCategoryId,
                SubCategoryName = y.y.SubCategoryName,
                ActualAmount    = y.x.ActualAmount,
                DebitDate       = y.x.Date,
                FinancialYear   = y.x.FinancialYear,
                ForMonth        = y.x.ForMonth,
                ExpectedAmount  = y.y.ExpectedAmount
            }).ToList();
            var _investmentData = model.InvestmentDetails.Join(categories, x => x.SubCategoryId, y => y.SubCategoryId, (x, y) => new { x, y }).Select
                                      (y => new MonthlyPlannerViewModel
            {
                InvestmentId    = y.x.InvestmentId,
                CategoryId      = y.y.CategoryId,
                CategoryName    = y.y.CategoryName,
                SubCategoryId   = y.y.SubCategoryId,
                SubCategoryName = y.y.SubCategoryName,
                ActualAmount    = y.x.ActualAmount,
                DebitDate       = y.x.DebitDate,
                FinancialYear   = y.x.FinancialYear,
                ForMonth        = y.x.ForMonth,
                ExpectedAmount  = y.y.ExpectedAmount
            }).ToList();

            model._MonthlyList = _incomeData;
            model._MonthlyList.AddRange(_expenseData);
            model._MonthlyList.AddRange(_savingsData);
            model._MonthlyList.AddRange(_investmentData);

            return(View("ViewPlanner", model));
        }
예제 #17
0
 public ItemDetailPage(IncomeDetail viewModel)
 {
     InitializeComponent();
     BindingContext = this.viewModel = viewModel;
 }