public void deleteDiscount(int id)
        {
            Discount Discount = DiscountRepository.GetById(id);

            DiscountRepository.Delete(Discount);
            SaveChange();
        }
Esempio n. 2
0
        public void DeleteDiscount(string id)
        {
            var _id = Convert.ToInt32(id);
            var tmp = _discountRepository.Get(d => d.Id == _id);

            _discountRepository.Delete(tmp);
            _unitOfWork.Commit();
        }
        public async Task <IResult> Delete(int id)
        {
            var query = await _discountRepository.Delete(id);

            if (query)
            {
                return(new SuccessResult("İndirim Silindi"));
            }
            return(new ErrorResult("İndirim Silinemedi"));
        }
Esempio n. 4
0
        public override async Task <DeleteDiscountResponse> DeleteDiscount(DeleteDiscountRequest request, ServerCallContext context)
        {
            var deleted = await _discountRepository.Delete(request.ProductName);

            _logger.LogInformation("Discount is successfully deleted. ProductName : {productName}", request.ProductName);

            var response = new DeleteDiscountResponse
            {
                Success = deleted
            };

            return(response);
        }
Esempio n. 5
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                _discountRep.Delete(id);
                _discountRep.Save();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Delete discount
        /// </summary>
        /// <param name="discount">Discount</param>
        public virtual void DeleteDiscount(Discount discount)
        {
            if (discount == null)
            {
                throw new ArgumentNullException("discount");
            }

            _discountRepository.Delete(discount);

            _cacheManager.GetCache(CACHE_NAME_DISCOUNTS).Clear();

            //event notification
            //_eventPublisher.EntityDeleted(discount);
        }
Esempio n. 7
0
        public ResponseVM <bool> deleteDiscount(int id)
        {
            var response = new ResponseVM <bool>();

            try
            {
                bool isSuccess = DiscountRepository.Delete(id);
                response.Response = isSuccess;
            }
            catch (Exception ex)
            {
                response.HasException = true;
                response.ErrorMsg     = ex.Message;
            }
            return(response);
        }
Esempio n. 8
0
 /// <summary>
 /// Method whose purpose is to delete an
 /// existing discount record from the database.
 /// </summary>
 /// <param name="discount">
 /// Existind discount model object.
 /// </param>
 /// <returns>
 /// Returns false if the query is successfully
 /// executed otherwise returns false.
 /// </returns>
 public bool Delete(DiscountModel discount)
 {
     return(_discountRepository.Delete(discount) > 0 ? true : false);
 }
Esempio n. 9
0
 public IActionResult Delete(int id)
 {
     _discountRepository.Delete(id);
     return(RedirectToAction("Index"));
 }
Esempio n. 10
0
        public async Task DeleteDiscount(int id)
        {
            await _repository.Delete(id);

            await _unit.Complete();
        }
 public async Task<ActionResult<bool>> DeleteDiscount(string productName)
 {
   return Ok(await _repository.Delete(productName));
 }
Esempio n. 12
0
        public ActionResult EditBenefitSetting(EditBenefitSettingModel model)
        {
            // if discounts are found then check if they are valid
            if (model.Discounts != null)
            {
                // Check if discounts all have percentages
                if (model.Discounts.Any(x => x.DiscountPercentage == null))
                {
                    ModelState.AddModelError("", "Discount % is required.");
                }

                // Check if all discounts that are no no condition have a name value.
                if (model.Discounts.Any(x => x.DiscountConditionTypeId != (int)Enums.Discount.ConditionType.NoCondition && string.IsNullOrEmpty(x.NameValueCondition)))
                {
                    ModelState.AddModelError("", "Name Condition is required.");
                }
            }

            if (ModelState.IsValid)
            {
                BenefitSetting benefitSetting = BenefitSettingsRepository.GetById(model.Id);

                benefitSetting.Name                        = model.Name;
                benefitSetting.AnnualSalary                = model.AnnualSalary.Value;
                benefitSetting.AnnualBenefitsCost          = model.BenefitCost.Value;
                benefitSetting.AnnualDependentBenefitsCost = model.DependantBenefitCost.Value;

                // only allow changing this field if user created the record.
                if (benefitSetting.CreatedById == User.Identity.GetUserId <int>())
                {
                    benefitSetting.IsPublic = model.IsPublic;
                }

                if (model.Discounts != null && model.Discounts.Any())
                {
                    DiscountRepository.Delete(DiscountRepository.GetByBenefitSettingsId(benefitSetting.Id).Where(x => model.Discounts.All(m => m.DiscountId != x.Id)));

                    foreach (var discount in model.Discounts)
                    {
                        Discount discountEntity = DiscountRepository.GetById(discount.DiscountId);
                        if (discountEntity != null)
                        {
                            discountEntity.DiscountTypeId          = discount.DiscountTypeId;
                            discountEntity.DiscountConditionTypeId = discount.DiscountConditionTypeId;
                            discountEntity.NameValueCondition      = discount.NameValueCondition;
                            discountEntity.DiscountPercentage      = discount.DiscountPercentage.Value;
                            DiscountRepository.Update(discountEntity);
                        }
                        else
                        {
                            benefitSetting.Discounts.Add(new Discount
                            {
                                DiscountTypeId          = discount.DiscountTypeId,
                                DiscountConditionTypeId = discount.DiscountConditionTypeId,
                                DiscountPercentage      = discount.DiscountPercentage.Value,
                                NameValueCondition      = discount.NameValueCondition
                            });
                        }
                    }
                }
                else
                {
                    DiscountRepository.Delete(DiscountRepository.GetByBenefitSettingsId(benefitSetting.Id));
                }

                benefitSetting = BenefitSettingsRepository.Update(benefitSetting);

                return(Json(new PostResultModel
                {
                    IsSuccess = true,
                    Message = "Benefit Setting Edited",
                    ItemId = benefitSetting.Id,
                    Html = PartialView("BenefitSettingRow", new BenefitSettingsRowModel(benefitSetting)).RenderToString()
                }));
            }

            return(PartialView(model));
        }