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); }
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); }
public ResultEntity <PromoCategoryEntity> Create(PromoCategoryEntity promocategoryEntity) { var validationResult = new ResultEntity <PromoCategoryEntity>(); using (var promocategoryDA = new PromoCategoryDA()) { validationResult.Value = promocategoryDA.Create(promocategoryEntity); } return(validationResult); }
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); }
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); }