public async Task <IActionResult> Edit(long id, [Bind("Id,CategoryCode,NameRu")] PaymentCategory paymentCategory)
        {
            if (id != paymentCategory.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(paymentCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaymentCategoryExists(paymentCategory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(paymentCategory));
        }
        public async Task <IActionResult> Create([Bind("Id,CategoryCode,NameRu")] PaymentCategory paymentCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(paymentCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(paymentCategory));
        }
Ejemplo n.º 3
0
        public PaymentCategory Get(int id)
        {
            var result = new PaymentCategory();

            try{
                result = context.PaymentCategories.Single(x => x.Id == id);
            }catch (System.Exception)
            {
                throw;
            }
            return(result);
        }
Ejemplo n.º 4
0
 public bool Save(PaymentCategory entity)
 {
     try{
         context.Add(entity);
         context.SaveChanges();
     }
     catch (System.Exception)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 5
0
 public bool Delete(int id)
 {
     try
     {
         var result = new PaymentCategory();
         result = context.PaymentCategories.Single(x => x.Id == id);
         context.Remove(result);
         context.SaveChanges();
         return(true);
     }
     catch (System.Exception)
     {
         throw;
     }
 }
Ejemplo n.º 6
0
        public bool Update(PaymentCategory entity)
        {
            try{
                var paymentcategoryOrigin = context.PaymentCategories.Single(
                    x => x.Id == entity.Id
                    );

                paymentcategoryOrigin.Id          = entity.Id;
                paymentcategoryOrigin.Name        = entity.Name;
                paymentcategoryOrigin.Status      = entity.Status;
                paymentcategoryOrigin.Description = entity.Description;
                context.Update(paymentcategoryOrigin);
                context.SaveChanges();
            }
            catch (System.Exception)
            {
                return(false);
            }
            return(true);
        }
 public static string ToDescription(this PaymentCategory category)
 {
     return(category.ToString());
 }
 public ActionResult Put([FromBody] PaymentCategory paymentCategory)
 {
     return(Ok(
                paymentCategoryService.Update(paymentCategory)
                ));
 }
Ejemplo n.º 9
0
 public Income(string name, int dateOfMonth, double paymentAmount,string frequency, PaymentCategory category)
     : this(name, dateOfMonth, paymentAmount, category)
 {
     //this.Frequency = (PaymentFrequency)Enum.Parse(typeof(PaymentFrequency), frequency.ToString(),true);
     this.Frequency = (PaymentFrequency) MapPaymentFrequency(frequency);
 }
Ejemplo n.º 10
0
 public Income(string name, int dateOfMonthPaymentMade, double incomeAmount, PaymentCategory category)
     : base(name, dateOfMonthPaymentMade, incomeAmount, category)
 {
     this.TypeOfPayment = PaymentType.Income;
 }
Ejemplo n.º 11
0
 public void Update(PaymentCategory entity)
 {
     _paymentRepository.Update(entity);
 }
Ejemplo n.º 12
0
 public Expense(string name, int dateOfMonth, double paymentAmount, PaymentCategory category)
     : base(name, dateOfMonth, paymentAmount, category)
 {
     this.TypeOfPayment = PaymentType.Expense;
 }
Ejemplo n.º 13
0
 public Payment(string name, int dateOfMonth, double paymentAmount, PaymentCategory category)
     : this(name,dateOfMonth,paymentAmount)
 {
     this._paymentCategory = category;
 }
Ejemplo n.º 14
0
 public ActionResult Save(PaymentCategory model)
 {
     repo.Save(model);
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 15
0
 public bool Update(PaymentCategory entity)
 {
     return(paymentRepository.Update(entity));
 }
Ejemplo n.º 16
0
 public bool Save(PaymentCategory entity)
 {
     return(paymentRepository.Save(entity));
 }
Ejemplo n.º 17
0
 public Expense(string name, int dateOfMonth, double paymentAmount,string frequency, PaymentCategory category)
     : this(name, dateOfMonth, paymentAmount, category)
 {
     this.Frequency = (PaymentFrequency)MapPaymentFrequency(frequency);
 }
Ejemplo n.º 18
0
 public void Add(PaymentCategory entity)
 {
     _paymentRepository.Add(entity);
 }