public async Task <IActionResult> PutArticles([FromRoute] Guid id, [FromBody] ArticlesDTO articles) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != articles.Id) { return(BadRequest()); } _context.Entry(articles).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArticlesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ArticlesVM(ArticlesDTO row) { Id_Article = row.Id_Article; Id_Author = row.Id_Author; Date_Added = row.Date_Added; Img_Path = row.Img_Path; Title = row.Title; Content = row.Content; Rating = row.Rating; }
public async Task <IActionResult> PostArticles([FromBody] ArticlesDTO articles) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Articles.Add(articles); await _context.SaveChangesAsync(); return(CreatedAtAction("GetArticles", new { id = articles.Id }, articles)); }
public List <ArticlesDTO> GetArticlesByEquipmentType(string pStrEquipmentTypeCode, string pStrContractTypeCode) { List <ArticlesDTO> lLstArticlesDTO = new List <ArticlesDTO>(); Recordset lObjRecordset = null; try { lObjRecordset = (Recordset)DIApplication.Company.GetBusinessObject(BoObjectTypes.BoRecordset); Dictionary <string, string> lLstStrParameters = new Dictionary <string, string>(); lLstStrParameters.Add("EquipmentTypeCode", pStrEquipmentTypeCode); lLstStrParameters.Add("ContractTypeCode", pStrContractTypeCode); string lStrQuery = this.GetSQL("GetArticlesByEquipmentType").Inject(lLstStrParameters); lObjRecordset.DoQuery(lStrQuery); if (lObjRecordset.RecordCount > 0) { for (int i = 0; i < lObjRecordset.RecordCount; i++) { ArticlesDTO lObjArticles = new ArticlesDTO { Code = int.Parse(lObjRecordset.Fields.Item("Code").Value.ToString()), ArticleCode = lObjRecordset.Fields.Item("ItemCode").Value.ToString(), Name = lObjRecordset.Fields.Item("ItemName").Value.ToString(), EquipmentTypeCode = lObjRecordset.Fields.Item("TypeEquipId").Value.ToString(), ContractTypeCode = lObjRecordset.Fields.Item("TypeContractId").Value.ToString(), UseDrilling = lObjRecordset.Fields.Item("U_UsePerfora").Value.ToString() == "N" ? false : true, }; lLstArticlesDTO.Add(lObjArticles); lObjRecordset.MoveNext(); } } } catch (Exception lObjException) { LogService.WriteError(string.Format("[ArticlesDAO - GetArticlesByEquipmentType: {0}]", lObjException.Message)); throw new DAOException(lObjException.Message, lObjException); } finally { MemoryUtility.ReleaseComObject(lObjRecordset); } return(lLstArticlesDTO); }