public JsonResultEntity Create([FromBody] FeedsEntity feedsEntity) { FeedsBL feedsBL = new FeedsBL(); JsonResultEntity response = new JsonResultEntity(); try { var result = feedsBL.Create(feedsEntity); 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 void ShouldInsertFeeds() { var bl = new FeedsBL(); var feed = new Feed { Sender = "busaco", Message = "It started raining.", PublishDate = new DateTime(2012, 2, 2), ReceiverGroups = new List<string> { "688936cd-b6ff-450a-b2ea-80573362e6de", "c920f326-5035-44d3-bd2f-690e2f831f1c" } }; bl.InsertFeed(feed); feed = new Feed { Sender = "rvlad", Faculty = "info.uaic.ro", Message = "It started raining.", PublishDate = new DateTime(2012, 2, 2), ReceiverGroups = new List<string> { "0f44bd29-26ee-4c50-a14f-0e641e1af8c8", "400e8981-feb5-4291-aa61-3044ff52d5a6" } }; bl.InsertFeed(feed); // list = bl.GetFeedsForGroup("info.uaic.ro", "asfasgasgasg"); // if (list == null) Assert.Fail(); // Assert.AreEqual(length + 2, list.Count); }
public JsonResultEntity Delete(int id) { var feedsBL = new FeedsBL(); JsonResultEntity response = new JsonResultEntity(); try { var result = feedsBL.DeleteById(id); if (result.HasWarning()) { response.Message = String.Join(",", result.Warning); return(response); } response.Success = true; response.Data = result.Value; } catch (Exception e) { response.Message = e.Message; LoggerHelper.Error(e); } return(response); }
public override JsonResultEntity Get([FromBody] DBParamEntity dbParamEntity) { FeedsBL feedsBL = new FeedsBL(); JsonResultEntity response = new JsonResultEntity(); try { var result = feedsBL.GetAll(dbParamEntity); if (result.HasWarning()) { response.Message = String.Join(",", result.Warning); return(response); } var dataFound = feedsBL.GetTotalRows(dbParamEntity); var totalPages = Convert.ToInt32(Math.Ceiling(dataFound.Value / Convert.ToDouble(dbParamEntity.Limit))); response.Success = true; response.Data = result.Value; response.MetaInfo = new MetaInfoEntity { DataFound = dataFound.Value, DataPerPage = dbParamEntity.Limit, Page = dbParamEntity.Page, TotalPages = totalPages == 0 ? 1 : totalPages }; } catch (Exception ex) { response.Message = ex.Message; LoggerHelper.Error(ex); } return(response); }