Пример #1
0
        public async Task <ResponceModel> Add([FromBody] EntryLike model)
        {
            var identifier = User.Claims.FirstOrDefault(p => p.Type == "id");

            if (identifier == null)
            {
                return(new ResponceModel(401, "FAILED", null, new string[] { "Yetkilendirme Hatası." }));
            }
            try
            {
                var user      = (await _userService.GetById(int.Parse(identifier.Value)));
                var entryLike = await _entryLikeService.Add(model);

                if (user.Id != entryLike.UserId)
                {
                    return(new ResponceModel(401, "FAILED", null, new string[] { "Yetkilendirme Hatası." }));
                }
                if (await _entryLikeService.SaveChangesAsync())
                {
                    return(new ResponceModel(200, "OK", entryLike, null));
                }
                else
                {
                    return(new ResponceModel(400, "FAILD", null, new string[] { "Veri eklenirken bir sorun oluştu." }));
                }
            }
            catch (Exception ex)
            {
                await _logService.Add(new SystemLog()
                {
                    Content = ex.Message, CreateDate = DateTime.Now, UserId = 0, EntityName = _entryLikeService.GetType().Name
                });

                return(new ResponceModel(500, "ERROR", null, new string[] { "Veri eklenirken bir sorun oluştu." }));
            }
        }
Пример #2
0
 public async Task <EntryLike> Add(EntryLike entryLike)
 {
     return(await _uow.Repository <EntryLike>().Insert(entryLike));
 }