public JsonResultEntity Create([FromBody] ParkingSpaceEntity parkingspaceEntity)
        {
            ParkingSpaceBL   parkingspaceBL = new ParkingSpaceBL();
            JsonResultEntity response       = new JsonResultEntity();

            try
            {
                var result = parkingspaceBL.Create(parkingspaceEntity);

                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 ParkingSpaceEntity Create(ParkingSpaceEntity parkingspaceEntity)
        {
            var query = @"INSERT INTO ""ParkingSpace""(""PlaceID"",""Floor"",""Spot"",""IsActive"",""IsVIP"",""Price"",""CreatedDate"",""ModifiedDate"",""ContributorID"") VALUES(@PlaceID,@Floor,@Spot,@IsActive,@IsVIP,@Price,@CreatedDate,@ModifiedDate,@ContributorID) RETURNING ""ID"";";

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

            parkingspaceEntity.ID = id;
            return(parkingspaceEntity);
        }
Ejemplo n.º 3
0
        public ResultEntity <ParkingSpaceEntity> Create(ParkingSpaceEntity parkingspaceEntity)
        {
            var validationResult = new ResultEntity <ParkingSpaceEntity>();

            using (var parkingspaceDA = new ParkingSpaceDA())
            {
                validationResult.Value = parkingspaceDA.Create(parkingspaceEntity);
            }

            return(validationResult);
        }
Ejemplo n.º 4
0
        public int Update(ParkingSpaceEntity parkingspaceEntity)
        {
            int affectedRows = 0;

            if (IsHaveId <ParkingSpaceEntity>(parkingspaceEntity) == false)
            {
                var query = @"UPDATE ""ParkingSpace"" SET ""PlaceID""=@PlaceID,""Floor""=@Floor,""Spot""=@Spot,""IsActive""=@IsActive,""IsVIP""=@IsVIP,""Price""=@Price,""CreatedDate""=@CreatedDate,""ModifiedDate""=@ModifiedDate,""ContributorID""=@ContributorID WHERE ""ID""=@ID";
                affectedRows = DbConnection.Execute(query, parkingspaceEntity);
            }

            return(affectedRows);
        }
Ejemplo n.º 5
0
        public ResultEntity <ParkingSpaceEntity> Update(ParkingSpaceEntity parkingspaceEntity)
        {
            var validationResult = new ResultEntity <ParkingSpaceEntity>();

            using (var parkingspaceDA = new ParkingSpaceDA())
            {
                var resultUpdate = parkingspaceDA.Update(parkingspaceEntity);

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

                validationResult.Value = parkingspaceEntity;
            }

            return(validationResult);
        }