示例#1
0
 public IActionResult ConditionCustomerTagInsert(CustomerReminderModel.ConditionModel.AddCustomerTagConditionModel model)
 {
     if (ModelState.IsValid)
     {
         _customerReminderViewModelService.InsertCustomerTagConditionModel(model);
         return(new NullJsonResult());
     }
     return(ErrorForKendoGridJson(ModelState));
 }
        public async Task <IActionResult> ConditionCustomerTagInsert(CustomerReminderModel.ConditionModel.AddCustomerTagConditionModel model)
        {
            if (ModelState.IsValid)
            {
                await _customerReminderViewModelService.InsertCustomerTagConditionModel(model);

                return(new JsonResult(""));
            }
            return(ErrorForKendoGridJson(ModelState));
        }
        public virtual async Task InsertCustomerTagConditionModel(CustomerReminderModel.ConditionModel.AddCustomerTagConditionModel model)
        {
            var customerReminder = await _customerReminderService.GetCustomerReminderById(model.CustomerReminderId);

            if (customerReminder != null)
            {
                var condition = customerReminder.Conditions.FirstOrDefault(x => x.Id == model.ConditionId);
                if (condition != null)
                {
                    if (condition.CustomerTags.Where(x => x == model.CustomerTagId).Count() == 0)
                    {
                        condition.CustomerTags.Add(model.CustomerTagId);
                        await _customerReminderService.UpdateCustomerReminder(customerReminder);
                    }
                }
            }
        }