コード例 #1
0
        public IHttpActionResult Post([FromBody] CompanyTypeDTO companyTypeDto)
        {
            var ret = _companyTypeService.AddNewCompanyType(companyTypeDto: companyTypeDto);

            if (ret == null)
            {
                return(BadRequest(message: _companyTypeService.LastErrorMessage));
            }
            return(CreatedAtRoute(routeName: "DefaultApi", routeValues: new { id = ret.Id }, content: ret));
        }
コード例 #2
0
        public async Task <ResponceModel> Update([FromRoute] int id, [FromBody] CompanyTypeDTO model)
        {
            var identifier = User.Claims.FirstOrDefault(p => p.Type == "id");

            if (identifier == null)
            {
                return(new ResponceModel(401, "FAILED", null, new string[] { "Yetkilendirme Hatası." }));
            }
            if (id == 0)
            {
                return(new ResponceModel(404, "ERROR", null, new string[] { "Güncellenecek veri bulunamadı" }));
            }
            try
            {
                var companyType = await companyTypeService.Get(id);

                if (companyType == null)
                {
                    return(new ResponceModel(404, "ERROR", null, new string[] { "Güncellenecek veri bulunamadı" }));
                }
                companyType = model.Adapt <CompanyType>();
                companyTypeService.Update(companyType);
                if (await companyTypeService.SaveChanges())
                {
                    return(new ResponceModel(200, "OK", null, null));
                }
                else
                {
                    return(new ResponceModel(400, "ERROR", null, new string[] { "Veri güncellenirken bir hata oluştu" }));
                }
            }
            catch (Exception ex)
            {
                await _logService.Add(new SystemLog()
                {
                    Content = ex.Message, CreateDate = DateTime.Now, UserId = 0, EntityName = companyTypeService.GetType().Name
                });

                return(new ResponceModel(500, "ERROR", null, new string[] { "Veri güncellenirken bir hata oluştu" }));
            }
        }
コード例 #3
0
 public IHttpActionResult Put([FromBody] CompanyTypeDTO companyTypeDto)
 {
     throw new NotImplementedException();
 }