public async Task <Response> Create(LeadCommentCreateModel leadCommentCreateModel, ClaimsPrincipal User) { using (var context = _applicationDbContextFactory.Create()) { User user = await UserManager.FindByNameAsync(User.Identity.Name); if (user != null) { var LeadComment = Mapper.Map <LeadComment>(leadCommentCreateModel); if (!context.Check <Lead>(leadCommentCreateModel.LeadId)) { return new Response { Status = 500, Message = "Такого лида нет!" } } ; LeadComment.UserId = user.Id; LeadComment.CommentDateTime = DateTime.Now; context.LeadComments.Add(LeadComment); context.SaveChanges(); return(new Response { Status = 100, Message = "Запрос успешно прошел." }); } else { return(null); } } } }
public async Task <ActionResult <Response> > Create(LeadCommentCreateModel model) { return(await _LeadCommentService.Create(model, User)); }