Пример #1
0
        public async Task <ResponceModel> Add([FromBody] Sector 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 sector = await sectorService.Add(model);

                if (await sectorService.SaveChanges())
                {
                    return(new ResponceModel(200, "OK", sector, null));
                }
                else
                {
                    return(new ResponceModel(404, "FAILD", null, new string[] { "Veri eklenirken sorun oluştu." }));
                }
            }
            catch (Exception ex)
            {
                await _logService.Add(new SystemLog()
                {
                    Content = ex.Message, CreateDate = DateTime.Now, UserId = 0, EntityName = sectorService.GetType().Name
                });

                return(new ResponceModel(400, "ERROR", null, new string[] { "Veri eklenirken sorun oluştu." }));
            }
        }