public virtual async Task <JsonResult> Add(ContactUs model) { if (!ModelState.IsValid) { return(Json(new { IsSuccessful = false, Message = ModelState.GetModelError() })); } model.UserId = User.GetUserId(); return(Json(await _ContactUsSrv.AddAsync(model))); }
public async Task <IActionResult> ContactUs([FromServices] IContactUsService contactUsService, ContactUs model) { if (!ModelState.IsValid) { return(Json(new { IsSuccessful = false, Message = ModelState.GetModelError() })); } if (User.Identity.IsAuthenticated) { model.UserId = User.GetUserId(); } return(Json(await contactUsService.AddAsync(model))); }
public async Task <IActionResult> Post([FromBody] ContactUsModel model) { int id = await _service.AddAsync(model); if (id > 0) { return(Ok()); } else { return(BadRequest()); } }