public JsonResultEntity Create([FromBody] PromoCategoryEntity promocategoryEntity)
        {
            PromoCategoryBL  promocategoryBL = new PromoCategoryBL();
            JsonResultEntity response        = new JsonResultEntity();

            try
            {
                var result = promocategoryBL.Create(promocategoryEntity);

                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);
        }
Esempio n. 2
0
        public PromoCategoryEntity Create(PromoCategoryEntity promocategoryEntity)
        {
            var query = @"INSERT INTO ""PromoCategory""(""CategoryName"",""Description"",""Logo"",""ModifiedDate"") VALUES(@CategoryName,@Description,@Logo,@ModifiedDate) RETURNING ""ID"";";

            int id = DbConnection.Query <int>(query, promocategoryEntity).Single();

            promocategoryEntity.ID = id;
            return(promocategoryEntity);
        }
Esempio n. 3
0
        public ResultEntity <PromoCategoryEntity> Create(PromoCategoryEntity promocategoryEntity)
        {
            var validationResult = new ResultEntity <PromoCategoryEntity>();

            using (var promocategoryDA = new PromoCategoryDA())
            {
                validationResult.Value = promocategoryDA.Create(promocategoryEntity);
            }

            return(validationResult);
        }
Esempio n. 4
0
        public int Update(PromoCategoryEntity promocategoryEntity)
        {
            int affectedRows = 0;

            if (IsHaveId <PromoCategoryEntity>(promocategoryEntity) == false)
            {
                var query = @"UPDATE ""PromoCategory"" SET ""CategoryName""=@CategoryName,""Description""=@Description,""Logo""=@Logo,""ModifiedDate""=@ModifiedDate WHERE ""ID""=@ID";
                affectedRows = DbConnection.Execute(query, promocategoryEntity);
            }

            return(affectedRows);
        }
Esempio n. 5
0
        public ResultEntity <PromoCategoryEntity> Update(PromoCategoryEntity promocategoryEntity)
        {
            var validationResult = new ResultEntity <PromoCategoryEntity>();

            using (var promocategoryDA = new PromoCategoryDA())
            {
                var resultUpdate = promocategoryDA.Update(promocategoryEntity);

                if (resultUpdate <= 0)
                {
                    validationResult.Warning.Add("Failed Updating PromoCategory!");
                    return(validationResult);
                }

                validationResult.Value = promocategoryEntity;
            }

            return(validationResult);
        }