public JsonResultEntity Create([FromBody] AppMessageEntity appmessageEntity) { AppMessageBL appmessageBL = new AppMessageBL(); JsonResultEntity response = new JsonResultEntity(); try { var result = appmessageBL.Create(appmessageEntity); 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 AppMessageEntity Create(AppMessageEntity appmessageEntity) { var query = @"INSERT INTO ""AppMessage""(""CriteriaCity"",""CriteriaGender"",""CriteriaAgeMin"",""CriteriaAgeMax"",""CriteriaDeviceOS"",""CriteriaDeviceBrand"",""CriteriaMember"",""Content"",""Weight"",""StartDate"",""EndDate"") VALUES(@CriteriaCity,@CriteriaGender,@CriteriaAgeMin,@CriteriaAgeMax,@CriteriaDeviceOS,@CriteriaDeviceBrand,@CriteriaMember,@Content,@Weight,@StartDate,@EndDate) RETURNING ""ID"";"; int id = DbConnection.Query <int>(query, appmessageEntity).Single(); appmessageEntity.ID = id; return(appmessageEntity); }
public ResultEntity <AppMessageEntity> Create(AppMessageEntity appmessageEntity) { var validationResult = new ResultEntity <AppMessageEntity>(); using (var appmessageDA = new AppMessageDA()) { validationResult.Value = appmessageDA.Create(appmessageEntity); } return(validationResult); }
public int Update(AppMessageEntity appmessageEntity) { int affectedRows = 0; if (IsHaveId <AppMessageEntity>(appmessageEntity) == false) { var query = @"UPDATE ""AppMessage"" SET ""CriteriaCity""=@CriteriaCity,""CriteriaGender""=@CriteriaGender,""CriteriaAgeMin""=@CriteriaAgeMin,""CriteriaAgeMax""=@CriteriaAgeMax,""CriteriaDeviceOS""=@CriteriaDeviceOS,""CriteriaDeviceBrand""=@CriteriaDeviceBrand,""CriteriaMember""=@CriteriaMember,""Content""=@Content,""Weight""=@Weight,""StartDate""=@StartDate,""EndDate""=@EndDate WHERE ""ID""=@ID"; affectedRows = DbConnection.Execute(query, appmessageEntity); } return(affectedRows); }
public ResultEntity <AppMessageEntity> Update(AppMessageEntity appmessageEntity) { var validationResult = new ResultEntity <AppMessageEntity>(); using (var appmessageDA = new AppMessageDA()) { var resultUpdate = appmessageDA.Update(appmessageEntity); if (resultUpdate <= 0) { validationResult.Warning.Add("Failed Updating AppMessage!"); return(validationResult); } validationResult.Value = appmessageEntity; } return(validationResult); }