Ejemplo n.º 1
0
        public ActionResult EditPaymentPerMonth(int id)
        {
            try
            {
                EditPaymentPerMonthDto model;
                PaymentPerMonth        dto = _paymentPerMonthRepository.Get(id);

                if (dto == null)
                {
                    return(Content("לא קיים תקציב."));
                }

                ViewBag.Budgets    = LoadBudgets();
                ViewBag.Categories = LoadCategories();

                model = Mapper.Map <EditPaymentPerMonthDto>(dto);
                return(View(model));
            }
            catch (Exception ex)
            {
                logger.Error($"EditPaymentPerMonth() {DateTime.Now}");
                logger.Error(ex.Message);
                logger.Error("==============================");
                return(null);
            }
        }
Ejemplo n.º 2
0
        public ActionResult AddPaymentPerMonth([Bind(Exclude = "Id")] AddPaymentPerMonthDto model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    ViewBag.Budgets    = LoadBudgets();
                    ViewBag.Categories = LoadCategories();
                    return(View(model));
                }

                PaymentPerMonth dto = Mapper.Map <PaymentPerMonth>(model);
                _paymentPerMonthRepository.Add(dto);
                InitState();

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                logger.Error($"AddPaymentPerMonth() {DateTime.Now}");
                logger.Error(ex.Message);
                logger.Error("==============================");
                return(null);
            }
        }
Ejemplo n.º 3
0
        public bool Delete(int id)
        {
            bool            isDeleted = false;
            PaymentPerMonth entity    = context.PaymentsPerMonths.FirstOrDefault(p => p.Id == id);

            if (entity != null)
            {
                context.PaymentsPerMonths.Remove(entity);
                context.SaveChanges();
                isDeleted = true;
            }
            return(isDeleted);
        }
Ejemplo n.º 4
0
        public bool Update(PaymentPerMonth item)
        {
            bool            isUpdated = false;
            PaymentPerMonth entity    = context.PaymentsPerMonths.FirstOrDefault(p => p.Id == item.Id);

            if (entity != null)
            {
                entity.CategoryID = item.CategoryID;
                entity.Sum        = item.Sum;
                entity.ActionDate = item.ActionDate;
                context.SaveChanges();
                isUpdated = true;
            }
            return(isUpdated);
        }
Ejemplo n.º 5
0
        public ActionResult EditPaymentPerMonth(EditPaymentPerMonthDto model)
        {
            try
            {
                //Check the model state
                if (!ModelState.IsValid)
                {
                    ViewBag.Budgets    = LoadBudgets();
                    ViewBag.Categories = LoadCategories();
                    return(View(model));
                }

                //Get the entity
                PaymentPerMonth dto = _paymentPerMonthRepository.Get(model.Id);

                if (dto == null)
                {
                    return(Content("תקציב לא קיים"));
                }
                else
                {
                    dto = Mapper.Map <PaymentPerMonth>(model);

                    //Update dto entity
                    _paymentPerMonthRepository.Update(dto);

                    ViewBag.Budgets    = LoadBudgets();
                    ViewBag.Categories = LoadCategories();
                    InitState();

                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                logger.Error($"EditMonthlyBudget() {DateTime.Now}");
                logger.Error(ex.Message);
                logger.Error("==============================");
                return(null);
            }
        }
Ejemplo n.º 6
0
 public void Add(PaymentPerMonth item)
 {
     context.PaymentsPerMonths.Add(item);
     context.SaveChanges();
 }