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));
        }
Beispiel #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);
        }
Beispiel #4
0
 public bool Save(PaymentCategory entity)
 {
     try{
         context.Add(entity);
         context.SaveChanges();
     }
     catch (System.Exception)
     {
         return(false);
     }
     return(true);
 }
Beispiel #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;
     }
 }
Beispiel #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)
                ));
 }
Beispiel #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);
 }
Beispiel #10
0
 public Income(string name, int dateOfMonthPaymentMade, double incomeAmount, PaymentCategory category)
     : base(name, dateOfMonthPaymentMade, incomeAmount, category)
 {
     this.TypeOfPayment = PaymentType.Income;
 }
Beispiel #11
0
 public void Update(PaymentCategory entity)
 {
     _paymentRepository.Update(entity);
 }
Beispiel #12
0
 public Expense(string name, int dateOfMonth, double paymentAmount, PaymentCategory category)
     : base(name, dateOfMonth, paymentAmount, category)
 {
     this.TypeOfPayment = PaymentType.Expense;
 }
Beispiel #13
0
 public Payment(string name, int dateOfMonth, double paymentAmount, PaymentCategory category)
     : this(name,dateOfMonth,paymentAmount)
 {
     this._paymentCategory = category;
 }
Beispiel #14
0
 public ActionResult Save(PaymentCategory model)
 {
     repo.Save(model);
     return(RedirectToAction("Index"));
 }
Beispiel #15
0
 public bool Update(PaymentCategory entity)
 {
     return(paymentRepository.Update(entity));
 }
Beispiel #16
0
 public bool Save(PaymentCategory entity)
 {
     return(paymentRepository.Save(entity));
 }
Beispiel #17
0
 public Expense(string name, int dateOfMonth, double paymentAmount,string frequency, PaymentCategory category)
     : this(name, dateOfMonth, paymentAmount, category)
 {
     this.Frequency = (PaymentFrequency)MapPaymentFrequency(frequency);
 }
Beispiel #18
0
 public void Add(PaymentCategory entity)
 {
     _paymentRepository.Add(entity);
 }