public JsonResultEntity Create([FromBody] ReportContentEntity reportcontentEntity) { ReportContentBL reportcontentBL = new ReportContentBL(); JsonResultEntity response = new JsonResultEntity(); try { var result = reportcontentBL.Create(reportcontentEntity); if (result.HasWarning()) { response.Message = String.Join(",", result.Warning); return(response); } response.Success = true; response.Data = result.Value; } catch (Exception ex) { response.Message = ex.Message; LoggerHelper.Error(ex); } return(response); }
public ReportContentEntity Create(ReportContentEntity reportcontentEntity) { var query = @"INSERT INTO ""ReportContent""(""Content"",""Category"",""Rating"",""Context"",""ReffID"",""Approved"",""Comment"",""CreatedDate"") VALUES(@Content,@Category,@Rating,@Context,@ReffID,@Approved,@Comment,@CreatedDate) RETURNING ""ID"";"; int id = DbConnection.Query <int>(query, reportcontentEntity).Single(); reportcontentEntity.ID = id; return(reportcontentEntity); }
public ResultEntity <ReportContentEntity> Create(ReportContentEntity reportcontentEntity) { var validationResult = new ResultEntity <ReportContentEntity>(); using (var reportcontentDA = new ReportContentDA()) { validationResult.Value = reportcontentDA.Create(reportcontentEntity); } return(validationResult); }
public int Update(ReportContentEntity reportcontentEntity) { int affectedRows = 0; if (IsHaveId <ReportContentEntity>(reportcontentEntity) == false) { var query = @"UPDATE ""ReportContent"" SET ""Content""=@Content,""Category""=@Category,""Rating""=@Rating,""Context""=@Context,""ReffID""=@ReffID,""Approved""=@Approved,""Comment""=@Comment,""CreatedDate""=@CreatedDate WHERE ""ID""=@ID"; affectedRows = DbConnection.Execute(query, reportcontentEntity); } return(affectedRows); }
public ResultEntity <ReportContentEntity> Update(ReportContentEntity reportcontentEntity) { var validationResult = new ResultEntity <ReportContentEntity>(); using (var reportcontentDA = new ReportContentDA()) { var resultUpdate = reportcontentDA.Update(reportcontentEntity); if (resultUpdate <= 0) { validationResult.Warning.Add("Failed Updating ReportContent!"); return(validationResult); } validationResult.Value = reportcontentEntity; } return(validationResult); }