public async Task <ActionResult> SaveData(NotificationChangeViewModel notifications) { if (notifications.updated != null) { foreach (var item in notifications.updated) { _notificationService.Update(item); } } if (notifications.deleted != null) { foreach (var item in notifications.deleted) { _notificationService.Delete(item); } } if (notifications.inserted != null) { foreach (var item in notifications.inserted) { _notificationService.Insert(item); } } await _unitOfWork.SaveChangesAsync(); return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); }
public async Task <JsonResult> SaveDataAsync(NotificationChangeViewModel notifications) { if (notifications == null) { throw new ArgumentNullException(nameof(notifications)); } if (notifications.updated != null) { foreach (var item in notifications.updated) { this.notificationService.Update(item); } } if (notifications.deleted != null) { foreach (var item in notifications.deleted) { this.notificationService.Delete(item); } } if (notifications.inserted != null) { foreach (var item in notifications.inserted) { this.notificationService.Insert(item); } } var result = await this.unitOfWork.SaveChangesAsync(); return(Json(new { success = true, result = result }, JsonRequestBehavior.AllowGet)); }