Ejemplo n.º 1
0
        public JsonResultEntity Create([FromBody] ParkingSpacePriceEntity parkingspacepriceEntity)
        {
            ParkingSpacePriceBL parkingspacepriceBL = new ParkingSpacePriceBL();
            JsonResultEntity    response            = new JsonResultEntity();

            try
            {
                var result = parkingspacepriceBL.Create(parkingspacepriceEntity);

                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 ParkingSpacePriceEntity Create(ParkingSpacePriceEntity parkingspacepriceEntity)
        {
            var query = @"INSERT INTO ""ParkingSpacePrice""(""ParkingSpaceID"",""StartDate"",""EndDate"",""Price"",""Category"",""CreatedDate"") VALUES(@ParkingSpaceID,@StartDate,@EndDate,@Price,@Category,@CreatedDate) RETURNING ""ID"";";

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

            parkingspacepriceEntity.ID = id;
            return(parkingspacepriceEntity);
        }
        public int Update(ParkingSpacePriceEntity parkingspacepriceEntity)
        {
            int affectedRows = 0;

            if (IsHaveId <ParkingSpacePriceEntity>(parkingspacepriceEntity) == false)
            {
                var query = @"UPDATE ""ParkingSpacePrice"" SET ""ParkingSpaceID""=@ParkingSpaceID,""StartDate""=@StartDate,""EndDate""=@EndDate,""Price""=@Price,""Category""=@Category,""ModifiedDate""=@ModifiedDate WHERE ""ID""=@ID";
                affectedRows = DbConnection.Execute(query, parkingspacepriceEntity);
            }

            return(affectedRows);
        }
        public ResultEntity <ParkingSpacePriceEntity> Create(ParkingSpacePriceEntity parkingspacepriceEntity)
        {
            var validationResult = new ResultEntity <ParkingSpacePriceEntity>();

            parkingspacepriceEntity.CreatedDate = DateTime.Now;

            using (var parkingspacepriceDA = new ParkingSpacePriceDA())
            {
                validationResult.Value = parkingspacepriceDA.Create(parkingspacepriceEntity);
            }

            return(validationResult);
        }
        public ResultEntity <ParkingSpacePriceEntity> Update(ParkingSpacePriceEntity parkingspacepriceEntity)
        {
            var validationResult = new ResultEntity <ParkingSpacePriceEntity>();

            parkingspacepriceEntity.ModifiedDate = DateTime.Now;

            using (var parkingspacepriceDA = new ParkingSpacePriceDA())
            {
                var resultUpdate = parkingspacepriceDA.Update(parkingspacepriceEntity);

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

                validationResult.Value = parkingspacepriceEntity;
            }

            return(validationResult);
        }