Beispiel #1
0
        public IActionResult Create(NotificationPreferrenceViewModel viewModel)
        {
            string message = string.Empty;

            string validationErrors = string.Join(",", ModelState.Values.Where(E => E.Errors.Count > 0)
                                                  .SelectMany(E => E.Errors)
                                                  .Select(E => E.ErrorMessage)
                                                  .ToArray());

            if (!ModelState.IsValid)
            {
                return(Json(new { success = false, reason = "Validation Failed. \n" + validationErrors }));
            }

            var obj = _mapper.Map <NotificationPreferrence>(viewModel);

            if (_messageService.Save(obj, ref message))
            {
                return(Json(new { success = true, reason = string.Empty }));
            }
            else
            {
                return(Json(new { success = false, reason = message }));
            }
        }
Beispiel #2
0
        public IActionResult Create(long Id)
        {
            NotificationPreferrenceViewModel viewModel = null;

            if (Id > 0)
            {
                var obj = _messageService.GetById(Id);
                viewModel = _mapper.Map <NotificationPreferrenceViewModel>(obj);
            }
            var model = Id == 0 ? new NotificationPreferrenceViewModel() : viewModel;

            return(PartialView(model));
        }