Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public ResultEntity <AppMessageEntity> Create(AppMessageEntity appmessageEntity)
        {
            var validationResult = new ResultEntity <AppMessageEntity>();

            using (var appmessageDA = new AppMessageDA())
            {
                validationResult.Value = appmessageDA.Create(appmessageEntity);
            }

            return(validationResult);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }