コード例 #1
0
 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)));
 }
コード例 #2
0
 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)));
 }
コード例 #3
0
        public async Task <IActionResult> Post([FromBody] ContactUsModel model)
        {
            int id = await _service.AddAsync(model);

            if (id > 0)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }