//[ValidateAntiForgeryToken] public async Task <ActionResult> Create(MobileComment mobileComment) { try { if (ModelState.IsValid) { //Create Trend mobileComment.UserId = 1; mobileComment.CreatedDateTime = DateTime.UtcNow; var result = await _mobileCommentBusinessService.CreateMobileComment(mobileComment); if (result.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError("", result.Exception); foreach (var error in result.Errors) { ModelState.AddModelError("", error); } } return(this.JsonNet(true)); } catch (Exception e) { return(this.JsonNet(false)); } }
public async Task <ValidationResult <MobileComment> > UpdateMobileComment(MobileComment mobileComment) { ValidationResult <MobileComment> validationResult = new ValidationResult <MobileComment>(); try { await _dataService.UpdateAsync(mobileComment); validationResult.Entity = mobileComment; validationResult.Succeeded = true; } catch (Exception ex) { validationResult.Succeeded = false; validationResult.Errors = new List <string> { ex.InnerMessage() }; validationResult.Exception = ex; } return(validationResult); }